Circuit UI Documentation

repository·main·Indexed 21 days ago

https://github.com/sumup-oss/circuit-ui

The web implementation of SumUp's Circuit Design System, providing a React-based component library and design tokens. Includes documentation for @sumup-oss/circuit-ui and @sumup-oss/design-tokens, as well as an ESLint plugin for managing component lifecycles, deprecated props, icons, and custom properties.

Tokens
119.2K
Snippets
341
Records
671
Agent score
75%

What's inside Circuit UI

  1. Overview of Circuit UI

    main
    Circuit UI is the web implementation of the SumUp Circuit Design System. It is designed to provide a consistent and inclusive user experience across various SumUp websites and applications while offering a developer-friendly component library. It is built to support a wide variety of web implementations using React and design tokens.
  2. Use icons with Buttons

    main

    Icons can be added to buttons to provide context or hint at behavior:

    • Leading Icons: Rendered on the leading side of the label to provide additional context (e.g., a search icon for a search submission).
    • Navigation Icons: Used to hint that the button performs an unexpected action, such as opening a dropdown or navigating to a new tab. Note: Navigation icons are not a substitute for leading icons and should not be used solely for context.
  3. Content guidelines for Toggletip elements

    main

    When composing the content of a Toggletip, follow these constraints to ensure usability:

    • Headline: Use only when necessary. It must be accompanied by body text. Keep it short (under 120 characters).
    • Body Text: Use for additional help or defining terms. Avoid essential instructions.
    • Action Button: Use to point users to more information or to enable a contextual action. Use a strong, clear imperative verb followed by a one-word object if needed (e.g., "Learn more").
  4. Choose a color scheme strategy

    main

    Depending on your application type, choose one of the following import strategies:

    Single color scheme

    For merchant-facing apps with one scheme, import @sumup-oss/design-tokens/light.css or @sumup-oss/design-tokens/dark.css. For consumer-facing apps, import @sumup-oss/design-tokens/consumer.css. Tokens are defined on :root.

    Scoped color scheme

    To apply a scheme to a specific subset of your app, import the -scoped versions: @sumup-oss/design-tokens/light-scoped.css, @sumup-oss/design-tokens/dark-scoped.css, or @sumup-oss/design-tokens/consumer-scoped.css. These use the data-color-scheme attribute. Note: You must also import a full theme to ensure all other tokens are defined.

    Multiple color schemes (Dynamic)

    For apps that switch between light and dark, import @sumup-oss/design-tokens/dynamic.css. This includes :root tokens, dark tokens scoped to prefers-color-scheme: dark, and the scoped themes. You can manually set the scheme by adding the data-color-scheme attribute to the document root.

  5. Use semantic color tokens instead of legacy tokens

    main

    Starting in v6.3, Circuit UI components (excluding the legacy Sidebar) use new semantic color tokens declared as CSS custom properties in BaseStyles. These tokens are designed to support theming and robust customization.

    Note: Legacy color tokens from @sumup/design-tokens are deprecated and scheduled for removal in a future major version. You should transition your custom styles to use the new semantic CSS custom properties.

  6. Ensure accessibility for RadioButtonInput

    main

    To maintain accessibility, every RadioButtonInput must have an accessible name (label). There are two primary ways to implement this:

    1. Nested Label (Recommended): Pass the label text as a child of the RadioButtonInput. This automatically renders the text inside a label element associated with the input, allowing users to activate the radio button by clicking the label.

      • Warning: Do not include interactive elements like anchors (<a>) or tooltips inside the label, as accessible names should not contain complex semantics or structure.
    2. ARIA Attributes (For separate labels): If the label must be visually or structurally separate from the input, use ARIA attributes to create the association:

      • Use aria-labelledby to associate the input with an existing label element.
      • Use aria-describedby to associate the input with additional descriptive context.
  7. Accessibility best practices for the Image component

    main

    When using the Image component, ensure you follow accessibility guidelines to comply with WCAG standards:

    • Alt Text: Always provide helpful alternative text to describe the content of the image for users relying on screen readers.
    • Avoid Images of Text: To comply with WCAG 1.4.5 (Level AA) and 1.4.9 (Level AAA), avoid using images that primarily contain text. Use actual text elements instead to ensure readability and accessibility.