• Introduction
    • Why Liquid
    • Getting started
    • CSS vs. Web Components
    • Component assets
    • Type checking and intellisense
    • Server-side rendering
    • Event handling
    • Form validation
    • React bindings
    • Tailwind CSS integration
    • Design tokens
    • Sandbox applications
    • FAQ
  • Globals
    • Animations
    • Border-radius
    • Colors
    • Focus
    • Fonts
    • Shadows
    • Spacings
    • Theming
    • Typography
  • Components
    • Accordion
      • Accordion Panel
      • Accordion Section
      • Accordion Toggle
    • Background Cells
    • Badge
    • Breadcrumbs
      • Crumb
    • Button
    • Card
    • Checkbox
    • Circular Progress
    • Header
    • Icon
    • Input
    • Input Message
    • Label
    • Link
    • Loading Indicator
    • Modal
    • Notice
    • Notification
    • Pagination
    • Progress
    • Radio Button
    • Screen Reader Live
    • Screen Reader Only
    • Select
      • Option
    • Sidenav
      • Sidenav Accordion
      • Sidenav Back
      • Sidenav Header
      • Sidenav Heading
      • Sidenav Navitem
      • Sidenav Separator
      • Sidenav Slider
      • Sidenav Subnav
      • Sidenav Toggle Outsid
    • Slider
    • Switch
      • Switch Item
    • Tabs
      • Tab
      • Tab List
      • Tab Panel
      • Tab Panel List
    • Toggle
    • Tooltip
    • Typography
  • Data Visualization
    • Getting Started
  1. Custom Elements are defined automatically
  2. Setting the asset path
Introduction React bindings

React bindings #

Setting event listeners via on<EventName>-prop on Liquid Oxygen Web Components does not work properly in React. For this reason, we provide special React bindings for Liquid Oxygen. They allow you to set event listeners via prop just like you are used to do in React without having to use reference.

All you need to do is to import and use the React binding of a Liquid Oxygen component instead of using the web component directly.

import { LdButton } from '@emdgroup-liquid/liquid/dist/react'

export default ({ buttonProps }) => (
{/* ... */}
<LdButton {...buttonProps} />
{/* ... */}
)

Custom Elements are defined automatically #

A positive side-effect of using React bindings is, that you do not need to call the defineCustomElements method manually, as the React bindings automatically take care of that.

For more details on React integration read the Stencil documentation.

Setting the asset path #

When using React bindings, you do not need to use the setAssetPath function to define the asset path for components like ld-icon. All you need to do is define a global variable on the window object to "tell" the Liquid components where they have to load their assets from:

  // if-clause only required when your code might also be executed
// on the server-side like with Next.js
if (typeof window !== "undefined") {
window.__LD_ASSET_PATH__ = window.location.origin + '/path/to/your/assets/';
}