Carbon Compose Multiplatform

repository·main·Indexed 43 days ago

https://github.com/gabrieldrn/carbon-compose

An unofficial implementation of IBM's Carbon Design System for Compose Multiplatform. It provides a suite of UI components, foundation elements (colors, themes, and typography), and testing utilities for building consistent interfaces across Android, iOS, Desktop, and Web (Wasm). Includes the core `io.github.gabrieldrn:carbon` library and a specialized `carbon-test` library for verifying design system states.

Tokens
3K
Snippets
7
Records
20
Agent score
54%

What's inside Carbon Compose

  1. Overview of the :carbon module

    main

    The :carbon module is the core foundation of the Carbon library. It is the source for the published io.github.gabrieldrn:carbon artifact. This module provides the essential design system elements, including:

    • Foundation elements: Colors, themes, and typography.
    • Component implementations: The full suite of UI components provided by Carbon.
  2. Overview of Carbon | Compose Multiplatform

    main

    Carbon | Compose Multiplatform is an unofficial Compose Multiplatform implementation of IBM's Carbon Design System. It provides UI components designed according to Carbon specifications for use in multiplatform applications.

    Supported Platforms:

    • Android
    • iOS
    • Desktop
    • Web (via Wasm)
  3. Use the carbon-test library for Carbon-specific testing

    main

    The carbon-test library provides testing utilities specifically designed for the Carbon API. It includes convenience functions for testing states that are not natively provided by the Compose framework, such as verifying the read-only state of a component.

    Important Constraint: Do not use this module as a dependency in your production code (commonMain). It is strictly intended for use within test source sets.

  4. Available UI Components in Carbon Compose

    main

    The library provides a variety of UI components. Note that implementations are currently limited as the library is under development.

    Input & Selection

    • Buttons: Button, Icon button, Icon button with popover.
    • Selection: Checkbox, Radio button, Toggle (Default and Small), Slider.
    • Text Input: Default text input, Text area, Password input.
    • Dropdowns: Default dropdown, Multi-select dropdown.
    • Date Picker: Simple date input, Single with calendar.
    • Navigation: Breadcrumb, TabItem.
    • Containers: Accordion, ContentSwitcher (Default and Icon), Popover (Popover box, Caret tip popover).

    Feedback & Information

    • Notifications: Actionable inline notification, Actionable toast notification, Callout notification, Inline notification, Toast notification.
    • Loading: Default loading, Small loading.
    • Progress: Default progress bar, Indeterminate progress bar.
    • Other: Tag (Read-only), Tooltip.
  5. Understand component size constraints and accessibility

    main

    Some components in Carbon Compose may lack certain size options (like Small or Medium) depending on the target platform. This is primarily driven by accessibility requirements for touch targets:

    • Android: Recommended minimum touch target is 48x48dp.
    • iOS: Recommended minimum touch target is 44x44pt.

    Carbon Compose follows these platform guidelines to ensure usability. For example, the Button and Dropdown components may lack Small and Medium sizes to maintain compliant touch targets.

    Warning: Some components currently provide sizes that do not comply with these accessibility guidelines; these non-compliant sizes are scheduled to be removed before version 1.0.0.

  6. Explore components with the Catalog App

    main

    The :catalog module is a Kotlin Multiplatform (KMP) application that serves as an interactive showcase. It allows you to test, explore, and visualize implemented components across all supported platforms (Android, iOS, Desktop, and Web via Wasm).

    To build and run the catalog app, refer to the specific documentation in the catalog/README.md file.

  7. How `:code-gen` works for Carbon tokens

    main

    The :code-gen module is responsible for generating Kotlin implementations of Carbon tokens. Currently, its scope is limited to generating Carbon theme implementations.

    When the main.kt entry point is executed, the module performs the following steps:

    1. Deserializes JSON files located in the resources folder.
    2. Generates Kotlin files into the :carbon module under the package com.gabrieldrn.carbon.foundation.color.

    Each generated file corresponds to a specific theme and contains the color definitions for that theme.

  8. Explore Carbon Compose Foundation elements

    main

    Carbon Compose provides foundational design elements to ensure visual consistency across your application. These include:

    • Themes: Pre-defined color themes including White, Grey10, Grey90, and Grey100.
    • Typography: Uses the IBM Plex font family.
    • Layering: Standardized layering system for depth and hierarchy.