suiss/ui · Component
Chip
A compact, selectable pill for filters and tags, with an optional icon and remove button.
Chip is an open-source component from suiss/ui for React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.


import { Chip } from "@/components/ui/chip"
export default function ChipDemo() {
return <Chip>Open now</Chip>
}import SwiftUI
struct ChipExample: View {
var body: some View {
ChipToggleDemo(title: "Open now", initial: false)
}
}
struct ChipToggleDemo: View {
let title: LocalizedStringKey
var size: ChipSize?
var icon: Image?
var onRemove: (() -> Void)?
@State private var selected: Boolimport androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.vector.ImageVector
import com.esuiss.ui.components.Chip
import com.esuiss.ui.components.ChipSize
@Composable
fun ChipItem(
text: String,
defaultSelected: Boolean = false,
size: ChipSize = ChipSize.Default,
enabled: Boolean = true,Chip is a toggle rendered as a rounded Pressable. It switches between an unselected bg-secondary background and a selected bg-foreground fill, and shrinks slightly while pressed. It has default and sm sizes, an optional leading icon, and an optional trailing remove button when onRemove is set.
ChipGroup manages selection for a set of chips: single selection by default, or several with multiple. It wraps chips onto new lines, or lays them out in a horizontal scroll view with scrollable.
Installation
$ pnpm dlx shadcn@latest add @esuiss/chipSee Installation for the components.json setup. Or use the suiss/ui CLI:
$ pnpm dlx @esuiss/ui@latest add chip$ pnpm dlx shadcn@latest add @esuiss/chipSee Installation for the components.json setup. Or use the suiss/ui CLI:
$ pnpm dlx @esuiss/ui@latest add chip --platform swift$ pnpm dlx shadcn@latest add @esuiss/chipSee Installation for the components.json setup. Or use the suiss/ui CLI:
$ pnpm dlx @esuiss/ui@latest add chip --platform kotlin- Install the following dependencies:
npx expo install class-variance-authority cn phosphor-react-native react-native-svgimport type { HostInstance } from "react-native"
import type {
BaseUIChangeEventDetails,
BaseUIGenericEventDetails,
ChangeEvent,
} from "./types"
const REASONS = {
none: "none",
triggerPress: "trigger-press",
triggerLongPress: "trigger-long-press",
outsidePress: "outside-press",
itemPress: "item-press",
closePress: "close-press",
backPress: "back-press",
accessibilityEscape: "accessibility-escape",import * as React from "react"
type HapticsImpactStyle = "light" | "medium" | "heavy" | "soft" | "rigid"
type HapticsNotificationType = "success" | "warning" | "error"
interface HapticsAdapter {
impact(style: HapticsImpactStyle): void
selection(): void
notification(type: HapticsNotificationType): void
}
interface HapticsContextValue {
adapter: HapticsAdapter | null
enabled: boolean
}import * as React from "react"
import { BackHandler } from "react-native"
function useEffectEvent<TArgs extends readonly unknown[], TResult>(
callback: (...args: TArgs) => TResult
): (...args: TArgs) => TResult {
const callbackRef = React.useRef(callback)
React.useLayoutEffect(() => {
callbackRef.current = callback
})
return React.useCallback(
(...args: TArgs): TResult => callbackRef.current(...args),
[]
)type AnyProps = Record<string, unknown>
type PropsGetter = (previous: AnyProps) => object
type MergePropsInput = object | PropsGetter | null | undefined
type Handler = (...args: unknown[]) => unknown
type StyleCallback = (state: never) => unknown
const EMPTY_PROPS: AnyProps = {}
function isEventHandler(key: string, value: unknown) {
const code0 = key.charCodeAt(0)
const code1 = key.charCodeAt(1)
const code2 = key.charCodeAt(2)import * as React from "react"
import { type LayoutRectangle, View } from "react-native"
import type { REASONS } from "./event-details"
import type {
BaseUIChangeEventDetails,
BaseUIComponentProps,
Orientation,
} from "./types"
import { useControllableState } from "./use-controllable-state"
import { useRender } from "./use-render"
type ToggleGroupChangeEventReason =
| typeof REASONS.itemPress
| typeof REASONS.none
type ToggleGroupChangeEventDetails =import * as React from "react"
import {
type GestureResponderEvent,
type LayoutChangeEvent,
type LayoutRectangle,
Pressable,
type View,
} from "react-native"
import { createChangeEventDetails, REASONS } from "./event-details"
import { useHaptics } from "./haptics"
import { useToggleGroupContext } from "./toggle-group"
import type { BaseUIChangeEventDetails, BaseUIComponentProps } from "./types"
import { useControllableState } from "./use-controllable-state"
import { useRender } from "./use-render"
type ToggleChangeEventReason =import type * as React from "react"
import type {
GestureResponderEvent,
HostInstance,
NativeSyntheticEvent,
StyleProp,
ViewStyle,
} from "react-native"
type Side = "top" | "bottom" | "left" | "right"
type Align = "start" | "center" | "end"
type Orientation = "horizontal" | "vertical"
type ComponentRenderFn<Props, State> = (
props: Props,
state: Stateimport * as React from "react"
import { useEffectEvent } from "./hooks"
import type { BaseUIChangeEventDetails } from "./types"
interface CancelableDetails {
readonly isCanceled: boolean
}
interface UseControllableStateParameters<
T,
Details extends CancelableDetails = BaseUIChangeEventDetails,
> {
value?: T | undefined
defaultValue: T
onChange?: ((value: T, details: Details) => void) | undefined
}import * as React from "react"
import { useComposedRefs } from "./hooks"
import { mergeClassNames, mergeProps, mergeStyles } from "./merge-props"
import type { ClassNameProp, RenderProp, StyleValue } from "./types"
type AnyProps = Record<string, unknown>
type RefInput<T> = React.Ref<T> | undefined
interface UseRenderParameters<State, RefType = unknown, Props = AnyProps> {
defaultComponent?: React.ElementType | undefined
render?: RenderProp<Props, State> | undefined
props?: object | readonly (object | null | undefined)[] | undefined
state?: State | undefined
ref?: RefInput<RefType> | readonly RefInput<RefType>[] | undefined
className?: ClassNameProp<State>- Copy and paste the following code into
components/ui/chip.tsx:
import { cva } from "class-variance-authority"
import { cn } from "cn"
import { type Icon as PhosphorIcon, XIcon } from "phosphor-react-native"
import * as React from "react"
import { Pressable, ScrollView } from "react-native"
import {
type ToggleChangeEventDetails,
Toggle as TogglePrimitive,
type ToggleState,
} from "@/components/primitives/toggle"
import { ToggleGroup as ToggleGroupPrimitive } from "@/components/primitives/toggle-group"
import { resolveClassName } from "@/components/primitives/use-render"
import { Icon, IconClassContext } from "@/components/ui/icon"
import { Text, TextClassContext } from "@/components/ui/text"
type ChipSize = "default" | "sm"- Update the import paths to match your project setup.
- Install the following dependencies:
npx expo install class-variance-authority cn phosphor-react-native react-native-svgimport type { HostInstance } from "react-native"
import type {
BaseUIChangeEventDetails,
BaseUIGenericEventDetails,
ChangeEvent,
} from "./types"
const REASONS = {
none: "none",
triggerPress: "trigger-press",
triggerLongPress: "trigger-long-press",
outsidePress: "outside-press",
itemPress: "item-press",
closePress: "close-press",
backPress: "back-press",
accessibilityEscape: "accessibility-escape",import * as React from "react"
type HapticsImpactStyle = "light" | "medium" | "heavy" | "soft" | "rigid"
type HapticsNotificationType = "success" | "warning" | "error"
interface HapticsAdapter {
impact(style: HapticsImpactStyle): void
selection(): void
notification(type: HapticsNotificationType): void
}
interface HapticsContextValue {
adapter: HapticsAdapter | null
enabled: boolean
}import * as React from "react"
import { BackHandler } from "react-native"
function useEffectEvent<TArgs extends readonly unknown[], TResult>(
callback: (...args: TArgs) => TResult
): (...args: TArgs) => TResult {
const callbackRef = React.useRef(callback)
React.useLayoutEffect(() => {
callbackRef.current = callback
})
return React.useCallback(
(...args: TArgs): TResult => callbackRef.current(...args),
[]
)type AnyProps = Record<string, unknown>
type PropsGetter = (previous: AnyProps) => object
type MergePropsInput = object | PropsGetter | null | undefined
type Handler = (...args: unknown[]) => unknown
type StyleCallback = (state: never) => unknown
const EMPTY_PROPS: AnyProps = {}
function isEventHandler(key: string, value: unknown) {
const code0 = key.charCodeAt(0)
const code1 = key.charCodeAt(1)
const code2 = key.charCodeAt(2)import * as React from "react"
import { type LayoutRectangle, View } from "react-native"
import type { REASONS } from "./event-details"
import type {
BaseUIChangeEventDetails,
BaseUIComponentProps,
Orientation,
} from "./types"
import { useControllableState } from "./use-controllable-state"
import { useRender } from "./use-render"
type ToggleGroupChangeEventReason =
| typeof REASONS.itemPress
| typeof REASONS.none
type ToggleGroupChangeEventDetails =import * as React from "react"
import {
type GestureResponderEvent,
type LayoutChangeEvent,
type LayoutRectangle,
Pressable,
type View,
} from "react-native"
import { createChangeEventDetails, REASONS } from "./event-details"
import { useHaptics } from "./haptics"
import { useToggleGroupContext } from "./toggle-group"
import type { BaseUIChangeEventDetails, BaseUIComponentProps } from "./types"
import { useControllableState } from "./use-controllable-state"
import { useRender } from "./use-render"
type ToggleChangeEventReason =import type * as React from "react"
import type {
GestureResponderEvent,
HostInstance,
NativeSyntheticEvent,
StyleProp,
ViewStyle,
} from "react-native"
type Side = "top" | "bottom" | "left" | "right"
type Align = "start" | "center" | "end"
type Orientation = "horizontal" | "vertical"
type ComponentRenderFn<Props, State> = (
props: Props,
state: Stateimport * as React from "react"
import { useEffectEvent } from "./hooks"
import type { BaseUIChangeEventDetails } from "./types"
interface CancelableDetails {
readonly isCanceled: boolean
}
interface UseControllableStateParameters<
T,
Details extends CancelableDetails = BaseUIChangeEventDetails,
> {
value?: T | undefined
defaultValue: T
onChange?: ((value: T, details: Details) => void) | undefined
}import * as React from "react"
import { useComposedRefs } from "./hooks"
import { mergeClassNames, mergeProps, mergeStyles } from "./merge-props"
import type { ClassNameProp, RenderProp, StyleValue } from "./types"
type AnyProps = Record<string, unknown>
type RefInput<T> = React.Ref<T> | undefined
interface UseRenderParameters<State, RefType = unknown, Props = AnyProps> {
defaultComponent?: React.ElementType | undefined
render?: RenderProp<Props, State> | undefined
props?: object | readonly (object | null | undefined)[] | undefined
state?: State | undefined
ref?: RefInput<RefType> | readonly RefInput<RefType>[] | undefined
className?: ClassNameProp<State>- Copy and paste the following code into
components/ui/chip.tsx:
import { cva } from "class-variance-authority"
import { cn } from "cn"
import { type Icon as PhosphorIcon, XIcon } from "phosphor-react-native"
import * as React from "react"
import { Pressable, ScrollView } from "react-native"
import {
type ToggleChangeEventDetails,
Toggle as TogglePrimitive,
type ToggleState,
} from "@/components/primitives/toggle"
import { ToggleGroup as ToggleGroupPrimitive } from "@/components/primitives/toggle-group"
import { resolveClassName } from "@/components/primitives/use-render"
import { Icon, IconClassContext } from "@/components/ui/icon"
import { Text, TextClassContext } from "@/components/ui/text"
type ChipSize = "default" | "sm"- Update the import paths to match your project setup.
- Install the following dependencies:
npx expo install phosphor-react-native react-native-svgimport type { HostInstance } from "react-native"
import type {
BaseUIChangeEventDetails,
BaseUIGenericEventDetails,
ChangeEvent,
} from "./types"
const REASONS = {
none: "none",
triggerPress: "trigger-press",
triggerLongPress: "trigger-long-press",
outsidePress: "outside-press",
itemPress: "item-press",
closePress: "close-press",
backPress: "back-press",
accessibilityEscape: "accessibility-escape",import * as React from "react"
type HapticsImpactStyle = "light" | "medium" | "heavy" | "soft" | "rigid"
type HapticsNotificationType = "success" | "warning" | "error"
interface HapticsAdapter {
impact(style: HapticsImpactStyle): void
selection(): void
notification(type: HapticsNotificationType): void
}
interface HapticsContextValue {
adapter: HapticsAdapter | null
enabled: boolean
}import * as React from "react"
import { BackHandler } from "react-native"
function useEffectEvent<TArgs extends readonly unknown[], TResult>(
callback: (...args: TArgs) => TResult
): (...args: TArgs) => TResult {
const callbackRef = React.useRef(callback)
React.useLayoutEffect(() => {
callbackRef.current = callback
})
return React.useCallback(
(...args: TArgs): TResult => callbackRef.current(...args),
[]
)type AnyProps = Record<string, unknown>
type PropsGetter = (previous: AnyProps) => object
type MergePropsInput = object | PropsGetter | null | undefined
type Handler = (...args: unknown[]) => unknown
type StyleCallback = (state: never) => unknown
const EMPTY_PROPS: AnyProps = {}
function isEventHandler(key: string, value: unknown) {
const code0 = key.charCodeAt(0)
const code1 = key.charCodeAt(1)
const code2 = key.charCodeAt(2)import * as React from "react"
import { type LayoutRectangle, View } from "react-native"
import type { REASONS } from "./event-details"
import type {
BaseUIChangeEventDetails,
BaseUIComponentProps,
Orientation,
} from "./types"
import { useControllableState } from "./use-controllable-state"
import { useRender } from "./use-render"
type ToggleGroupChangeEventReason =
| typeof REASONS.itemPress
| typeof REASONS.none
type ToggleGroupChangeEventDetails =import * as React from "react"
import {
type GestureResponderEvent,
type LayoutChangeEvent,
type LayoutRectangle,
Pressable,
type View,
} from "react-native"
import { createChangeEventDetails, REASONS } from "./event-details"
import { useHaptics } from "./haptics"
import { useToggleGroupContext } from "./toggle-group"
import type { BaseUIChangeEventDetails, BaseUIComponentProps } from "./types"
import { useControllableState } from "./use-controllable-state"
import { useRender } from "./use-render"
type ToggleChangeEventReason =import type * as React from "react"
import type {
GestureResponderEvent,
HostInstance,
NativeSyntheticEvent,
StyleProp,
ViewStyle,
} from "react-native"
type Side = "top" | "bottom" | "left" | "right"
type Align = "start" | "center" | "end"
type Orientation = "horizontal" | "vertical"
type ComponentRenderFn<Props, State> = (
props: Props,
state: Stateimport * as React from "react"
import { useEffectEvent } from "./hooks"
import type { BaseUIChangeEventDetails } from "./types"
interface CancelableDetails {
readonly isCanceled: boolean
}
interface UseControllableStateParameters<
T,
Details extends CancelableDetails = BaseUIChangeEventDetails,
> {
value?: T | undefined
defaultValue: T
onChange?: ((value: T, details: Details) => void) | undefined
}import * as React from "react"
import { useComposedRefs } from "./hooks"
import { mergeClassNames, mergeProps, mergeStyles } from "./merge-props"
import type { ClassNameProp, RenderProp, StyleValue } from "./types"
type AnyProps = Record<string, unknown>
type RefInput<T> = React.Ref<T> | undefined
interface UseRenderParameters<State, RefType = unknown, Props = AnyProps> {
defaultComponent?: React.ElementType | undefined
render?: RenderProp<Props, State> | undefined
props?: object | readonly (object | null | undefined)[] | undefined
state?: State | undefined
ref?: RefInput<RefType> | readonly RefInput<RefType>[] | undefined
className?: ClassNameProp<State>- Copy and paste the following code into
components/ui/chip.tsx:
import { type Icon as PhosphorIcon, XIcon } from "phosphor-react-native"
import * as React from "react"
import {
Pressable,
ScrollView,
type StyleProp,
StyleSheet,
type TextStyle,
type ViewStyle,
} from "react-native"
import {
type ToggleChangeEventDetails,
Toggle as TogglePrimitive,
type ToggleState,
} from "@/components/primitives/toggle"
import { ToggleGroup as ToggleGroupPrimitive } from "@/components/primitives/toggle-group"- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
.package(url: "https://github.com/phosphor-icons/swift", from: "2.1.0")- Copy the theme files every view uses:
import CoreText
import SwiftUI
import UIKit
struct RGBA: Sendable {
let red: CGFloat
let green: CGFloat
let blue: CGFloat
let alpha: CGFloat
init(_ hex: UInt32, _ alpha: CGFloat = 1) {
red = CGFloat((hex >> 16) & 0xFF) / 255
green = CGFloat((hex >> 8) & 0xFF) / 255
blue = CGFloat(hex & 0xFF) / 255
self.alpha = alpha
}import SwiftUI
public enum EsuissColor {
public static let background = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))
public static let foreground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
public static let card = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
public static let cardForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
public static let popover = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
public static let popoverForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
public static let primary = Color.adaptive(light: .init(0x0071E3), dark: .init(0x0A84FF))
public static let primaryForeground = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0xFFFFFF))
public static let secondary = Color.adaptive(light: .init(0x000000, 0.04), dark: .init(0xFFFFFF, 0.1))
public static let secondaryForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
public static let muted = Color.adaptive(light: .init(0xF5F5F7), dark: .init(0x161617))
public static let mutedForeground = Color.adaptive(light: .init(0x6E6E73), dark: .init(0x86868B))
public static let accent = Color.adaptive(light: .init(0x000000, 0.06), dark: .init(0xFFFFFF, 0.1))- Copy the source and every file it uses:
import PhosphorSwift
import SwiftUI
public enum ChipSize: CaseIterable, Sendable {
case sm, `default`
var height: CGFloat {
switch self {
case .sm: 28
case .default: 32
}
}
var padding: CGFloat {
switch self {
case .sm: 10import SwiftUI
public struct VariantButtonStyle: ButtonStyle {
public enum Variant: CaseIterable, Sendable {
case `default`, outline, secondary, tinted, ghost, plain, destructive, link
}
public enum Size: CaseIterable, Sendable {
case `default`, xs, sm, lg, xl, form, icon, iconXs, iconSm, iconLg, iconXl
var height: CGFloat {
switch self {
case .xs, .iconXs: Metrics.Height.buttonXs
case .sm, .iconSm: Metrics.Height.buttonSm
case .default, .icon: Metrics.Height.button
case .lg, .iconLg: Metrics.Height.buttonLgimport SwiftUI
extension EnvironmentValues {
@Entry var buttonGroup: Axis? = nil
@Entry var buttonGroupSize: CGSize = .zero
}
enum ButtonGroupSpace: Hashable {
case group
}
struct ButtonGroupFrame {
let bounds: Anchor<CGRect>
let outlined: Bool
}import PhosphorSwift
import SwiftUI
extension Shadow {
static let control = Shadow(color: .black.opacity(0.08), radius: 0.5, y: 0.5)
static let thumb = Shadow(color: .black.opacity(0.12), radius: 1.5, y: 1)
}
struct SelectionIndicator<Mark: View>: View {
let checked: Bool
let pressed: Bool
let cornerRadius: CGFloat
let mark: Mark
@Environment(\.isEnabled) private var isEnabled
@Environment(\.isInvalid) private var invalidimport PhosphorSwift
import SwiftUI
public struct Combobox<Item: Hashable & Sendable>: View {
let items: [Item]
let single: Binding<Item?>?
let multiple: Binding<[Item]>?
let placeholder: LocalizedStringKey
let searchPlaceholder: LocalizedStringKey
let emptyText: LocalizedStringKey
let title: (Item) -> String
@State private var open = false
@Environment(\.isEnabled) private var isEnabled
public init(import PhosphorSwift
import SwiftUI
enum MenuPresentation: Sendable {
case system, popup
}
extension EnvironmentValues {
@Entry var menuPresentation: MenuPresentation = .system
@Entry var menuRadio = MenuRadioContext()
}
struct MenuRadioContext: @unchecked Sendable {
var selected: AnyHashable?
var select: @MainActor @Sendable (AnyHashable) -> Void = { _ in }
}import SwiftUI
extension EnvironmentValues {
@Entry public var isInvalid = false
@Entry var fieldInset = false
@Entry var fieldSize = FieldSize.default
@Entry var fieldGroupInset = false
@Entry var fieldSetInset = false
}
extension View {
public func invalid(_ isInvalid: Bool = true) -> some View {
environment(\.isInvalid, isInvalid)
}
}import SwiftUI
extension EnvironmentValues {
@Entry public var hapticsEnabled = true
}
extension View {
public func haptics(_ enabled: Bool) -> some View {
environment(\.hapticsEnabled, enabled)
}
func hapticFeedback<Trigger: Equatable>(_ feedback: SensoryFeedback, trigger: Trigger) -> some View {
modifier(HapticFeedbackModifier(feedback: feedback, trigger: trigger) { _, _ in true })
}
func hapticFeedback<Trigger: Equatable>(import SwiftUI
public struct InputStyle: TextFieldStyle {
public enum Size: CaseIterable, Sendable {
case `default`, md, sm, lg
var height: CGFloat {
switch self {
case .default: Metrics.Height.input
case .md: 36
case .sm: 32
case .lg: InputMetrics.largeHeight
}
}
var horizontalPadding: CGFloat {import SwiftUI
public enum ItemVariant: CaseIterable, Sendable {
case `default`, outline, muted
}
public enum ItemSize: CaseIterable, Sendable {
case `default`, sm, xs
var horizontalPadding: CGFloat {
switch self {
case .default: 16
case .sm: 14
case .xs: 12
}
}import Observation
import PhosphorSwift
import SwiftUI
public enum PopupAlignment: Sendable, CaseIterable {
case start, center, end
}
struct OverlayDismiss: Sendable {
let action: @MainActor @Sendable () -> Void
@MainActor func callAsFunction() {
action()
}
}import PhosphorSwift
import SwiftUI
struct SelectContext: @unchecked Sendable {
var selected: AnyHashable?
var registering = false
var select: @MainActor @Sendable (AnyHashable) -> Void = { _ in }
}
extension EnvironmentValues {
@Entry var select = SelectContext()
}
struct SelectLabelsKey: PreferenceKey {
static var defaultValue: [AnyHashable: Text] { [:] }import SwiftUI
public struct Separator: View {
let orientation: Axis
public init(_ orientation: Axis = .horizontal) {
self.orientation = orientation
}
public var body: some View {
Rectangle()
.fill(EsuissColor.border)
.frame(width: orientation == .vertical ? 1 : nil, height: orientation == .horizontal ? 1 : nil)
.frame(maxWidth: orientation == .horizontal ? .infinity : nil, maxHeight: orientation == .vertical ? .infinity : nil)
.accessibilityHidden(true)
}- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
plugins {
id("org.jetbrains.kotlin.plugin.compose")
}
android {
compileSdk = 37
defaultConfig { minSdk = 24 }
buildFeatures { compose = true }
}
dependencies {
implementation(platform("androidx.compose:compose-bom:2026.09.00"))
implementation("androidx.compose.foundation:foundation")
implementation("androidx.compose.ui:ui")
implementation("com.adamglin:phosphor-icon-android:1.0.0")
}- Copy the theme files every view uses:
package com.esuiss.ui.theme
import android.content.res.AssetManager
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.dropShadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.shadow.Shadow as DropShadow
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Fontpackage com.esuiss.ui.theme
import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
@Immutable
data class Colors(
val background: Color,
val foreground: Color,
val card: Color,
val cardForeground: Color,
val popover: Color,
val popoverForeground: Color,
val primary: Color,- Copy the source and every file it uses:
package com.esuiss.ui.components
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.paddingpackage com.esuiss.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextpackage com.esuiss.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Immutablepackage com.esuiss.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.selection.triStateToggleable
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alphapackage com.esuiss.ui.components
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
val LocalContentStyle = compositionLocalOf { TextStyle.Default }
val LocalContentColor = compositionLocalOf { Color.Unspecified }
val LocalIconSize = compositionLocalOf { 20.dp }package com.esuiss.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.LayoutScopeMarker
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextpackage com.esuiss.ui.components
import android.provider.Settings
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.text.selection.TextSelectionColors
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Offsetpackage com.esuiss.ui.components
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.hapticfeedback.HapticFeedback
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback
val LocalHapticsEnabled = staticCompositionLocalOf { true }
@Composable
fun ProvideHaptics(enabled: Boolean, content: @Composable () -> Unit) {
CompositionLocalProvider(LocalHapticsEnabled provides enabled, content = content)
}package com.esuiss.ui.components
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.Dp
import com.esuiss.ui.theme.EsuissTheme
@Composable
fun Icon(
imageVector: ImageVector,package com.esuiss.ui.components
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.esuiss.ui.theme.EsuissTheme
import com.esuiss.ui.theme.Typographypackage com.esuiss.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.theme.EsuissTheme
@Composable
fun Separator(- Update the
com.esuiss.uipackage names to match your project.
Usage
import { Chip, ChipGroup } from "@/components/ui/chip"<Chip>Open now</Chip>import SwiftUI
struct ChipExample: View {
var body: some View {
ChipToggleDemo(title: "Open now", initial: false)
}
}
struct ChipToggleDemo: View {
let title: LocalizedStringKey
var size: ChipSize?
var icon: Image?
var onRemove: (() -> Void)?
@State private var selected: Bool
init(
title: LocalizedStringKey,
initial: Bool,
size: ChipSize? = nil,
icon: Image? = nil,
onRemove: (() -> Void)? = nil
) {
self.title = title
self.size = size
self.icon = icon
self.onRemove = onRemove
_selected = State(initialValue: initial)
}
var body: some View {
Chip(title, isSelected: $selected, size: size, icon: icon, onRemove: onRemove)
}
}import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.graphics.vector.ImageVector
import com.esuiss.ui.components.Chip
import com.esuiss.ui.components.ChipSize
@Composable
fun ChipItem(
text: String,
defaultSelected: Boolean = false,
size: ChipSize = ChipSize.Default,
enabled: Boolean = true,
icon: ImageVector? = null,
onRemove: (() -> Unit)? = null,
) {
var selected by rememberSaveable { mutableStateOf(defaultSelected) }
Chip(
text,
selected = selected,
onSelectedChange = { selected = it },
size = size,
enabled = enabled,
icon = icon,
onRemove = onRemove,
)
}
@Composable
fun ChipDefault() {
Column {
ChipItem("Open now")
}
}Examples
States
Unselected, selected and disabled chips.


import { View } from "react-native"
import { Chip } from "@/components/ui/chip"
import { Text } from "@/components/ui/text"
export default function ChipStates() {
return (
<View className="gap-4">
<View className="gap-2">
<Text variant="muted">Unselected</Text>
<Chip>Open now</Chip>
</View>
<View className="gap-2">
<Text variant="muted">Selected</Text>
<Chip defaultSelected>Open now</Chip>
</View>
<View className="gap-2">import { View } from "react-native"
import { Chip } from "@/components/ui/chip"
import { Text } from "@/components/ui/text"
export default function ChipStates() {
return (
<View style={{ gap: 16 }}>
<View style={{ gap: 8 }}>
<Text variant="muted">Unselected</Text>
<Chip>Open now</Chip>
</View>
<View style={{ gap: 8 }}>
<Text variant="muted">Selected</Text>
<Chip defaultSelected>Open now</Chip>
</View>
<View style={{ gap: 8 }}>import SwiftUI
struct ChipStatesExample: View {
var body: some View {
VStack(alignment: .leading, spacing: 16) {
ChipSection(label: "Unselected") {
ChipToggleDemo(title: "Open now", initial: false)
}
ChipSection(label: "Selected") {
ChipToggleDemo(title: "Open now", initial: true)
}
ChipSection(label: "Disabled") {
HStack(spacing: 8) {
Chip("Open now", isSelected: .constant(false))
Chip("Open now", isSelected: .constant(true))
}import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Chip
import com.esuiss.ui.components.ChipSize
import com.esuiss.ui.components.Text
import com.esuiss.ui.components.TextVariantSizes
The default and sm sizes, set with size.
The group's size is passed to every chip unless a chip sets its own.


import { StarIcon } from "phosphor-react-native"
import { View } from "react-native"
import { Chip } from "@/components/ui/chip"
import { Text } from "@/components/ui/text"
export default function ChipSizes() {
return (
<View className="gap-4">
<View className="gap-2">
<Text variant="muted">Default</Text>
<View className="flex-row gap-2">
<Chip icon={StarIcon}>Top rated</Chip>
<Chip icon={StarIcon} defaultSelected>
Top rated
</Chip>
<Chip onRemove={() => undefined}>Nearby</Chip>import { StarIcon } from "phosphor-react-native"
import { View } from "react-native"
import { Chip } from "@/components/ui/chip"
import { Text } from "@/components/ui/text"
export default function ChipSizes() {
return (
<View style={{ gap: 16 }}>
<View style={{ gap: 8 }}>
<Text variant="muted">Default</Text>
<View style={{ flexDirection: "row", gap: 8 }}>
<Chip icon={StarIcon}>Top rated</Chip>
<Chip icon={StarIcon} defaultSelected>
Top rated
</Chip>
<Chip onRemove={() => undefined}>Nearby</Chip>import PhosphorSwift
import SwiftUI
struct ChipSizesExample: View {
var body: some View {
VStack(alignment: .leading, spacing: 16) {
ChipSection(label: "Default") {
HStack(spacing: 8) {
ChipToggleDemo(title: "Top rated", initial: false, icon: Ph.star.regular)
ChipToggleDemo(title: "Top rated", initial: true, icon: Ph.star.regular)
ChipToggleDemo(title: "Nearby", initial: false, onRemove: {})
}
}
ChipSection(label: "Small") {
HStack(spacing: 8) {
ChipToggleDemo(title: "Top rated", initial: false, size: .sm, icon: Ph.star.regular)import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.Star
import com.esuiss.ui.components.ChipWith icon
Pass an icon to show it before the label.
import {
CalendarBlankIcon,
CoffeeIcon,
ForkKnifeIcon,
MapPinIcon,
} from "phosphor-react-native"
import { View } from "react-native"
import { Chip } from "@/components/ui/chip"
export default function ChipWithIcon() {
return (
<View className="flex-row flex-wrap gap-2">
<Chip icon={CoffeeIcon}>Coffee</Chip>
<Chip icon={ForkKnifeIcon} defaultSelected>
Restaurants
</Chip>import {
CalendarBlankIcon,
CoffeeIcon,
ForkKnifeIcon,
MapPinIcon,
} from "phosphor-react-native"
import { View } from "react-native"
import { Chip } from "@/components/ui/chip"
export default function ChipWithIcon() {
return (
<View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8 }}>
<Chip icon={CoffeeIcon}>Coffee</Chip>
<Chip icon={ForkKnifeIcon} defaultSelected>
Restaurants
</Chip>import PhosphorSwift
import SwiftUI
struct ChipWithIconExample: View {
var body: some View {
FlowRow(spacing: 8) {
ChipToggleDemo(title: "Coffee", initial: false, icon: Ph.coffee.regular)
ChipToggleDemo(title: "Restaurants", initial: true, icon: Ph.forkKnife.regular)
ChipToggleDemo(title: "Nearby", initial: false, icon: Ph.mapPin.regular)
ChipToggleDemo(title: "Tonight", initial: false, icon: Ph.calendarBlank.regular)
.disabled(true)
}
}
}
struct ChipToggleDemo: View {import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.CalendarBlank
import com.adamglin.phosphoricons.regular.Coffee
import com.adamglin.phosphoricons.regular.ForkKnifeRemovable
Set onRemove to show a remove button. It is called when the button is pressed.
Use removeLabel to localize the remove button's label.


import * as React from "react"
import { View } from "react-native"
import { Chip } from "@/components/ui/chip"
import { Text } from "@/components/ui/text"
export default function ChipRemovable() {
const [tags, setTags] = React.useState([
"Design",
"Mobile",
"Accessibility",
"Motion",
])
return (
<View className="gap-3">
<View className="flex-row flex-wrap gap-2">
{tags.map((tag) => (import * as React from "react"
import { View } from "react-native"
import { Chip } from "@/components/ui/chip"
import { Text } from "@/components/ui/text"
export default function ChipRemovable() {
const [tags, setTags] = React.useState([
"Design",
"Mobile",
"Accessibility",
"Motion",
])
return (
<View style={{ gap: 12 }}>
<View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8 }}>
{tags.map((tag) => (import SwiftUI
struct ChipRemovableDemo: View {
@State private var tags = ["Design", "Mobile", "Accessibility", "Motion"]
@State private var selected: Set<String> = []
var body: some View {
VStack(alignment: .leading, spacing: 12) {
FlowRow(spacing: 8) {
ForEach(tags, id: \.self) { tag in
Chip(isSelected: binding(tag), onRemove: {
withAnimation { tags.removeAll { $0 == tag } }
}) {
Text(verbatim: tag)
}
}import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Chip
import com.esuiss.ui.components.Text
import com.esuiss.ui.components.TextVariant
@ComposableControlled
A chip controlled with selected and onSelectedChange.


import * as React from "react"
import { View } from "react-native"
import { Chip } from "@/components/ui/chip"
import { Text } from "@/components/ui/text"
export default function ChipControlled() {
const [selected, setSelected] = React.useState(true)
return (
<View className="gap-3">
<Chip selected={selected} onSelectedChange={setSelected}>
Free delivery
</Chip>
<Text variant="muted">{selected ? "Selected" : "Not selected"}</Text>
</View>
)
}import * as React from "react"
import { View } from "react-native"
import { Chip } from "@/components/ui/chip"
import { Text } from "@/components/ui/text"
export default function ChipControlled() {
const [selected, setSelected] = React.useState(true)
return (
<View style={{ gap: 12 }}>
<Chip selected={selected} onSelectedChange={setSelected}>
Free delivery
</Chip>
<Text variant="muted">{selected ? "Selected" : "Not selected"}</Text>
</View>
)
}import SwiftUI
struct ChipControlledDemo: View {
@State private var selected = true
var body: some View {
VStack(alignment: .leading, spacing: 12) {
Chip("Free delivery", isSelected: $selected)
Text(selected ? "Selected" : "Not selected").textVariant(.muted)
}
}
}import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.Chip
import com.esuiss.ui.components.Text
import com.esuiss.ui.components.TextVariant
@Composable
fun ChipControlled() {Group single
A ChipGroup allows one selected chip by default.


import * as React from "react"
import { View } from "react-native"
import { Chip, ChipGroup } from "@/components/ui/chip"
import { Text } from "@/components/ui/text"
export default function ChipGroupSingle() {
const [value, setValue] = React.useState(["all"])
return (
<View className="gap-3">
<ChipGroup value={value} onValueChange={setValue}>
<Chip value="all">All</Chip>
<Chip value="coffee">Coffee</Chip>
<Chip value="lunch">Lunch</Chip>
<Chip value="dinner">Dinner</Chip>
</ChipGroup>
<Text variant="muted">Selected: {value.join(", ") || "none"}</Text>import * as React from "react"
import { View } from "react-native"
import { Chip, ChipGroup } from "@/components/ui/chip"
import { Text } from "@/components/ui/text"
export default function ChipGroupSingle() {
const [value, setValue] = React.useState(["all"])
return (
<View style={{ gap: 12 }}>
<ChipGroup value={value} onValueChange={setValue}>
<Chip value="all">All</Chip>
<Chip value="coffee">Coffee</Chip>
<Chip value="lunch">Lunch</Chip>
<Chip value="dinner">Dinner</Chip>
</ChipGroup>
<Text variant="muted">Selected: {value.join(", ") || "none"}</Text>import SwiftUI
struct ChipCategory: Hashable {
let value: String
let label: String
}
@MainActor let chipCategories = [
ChipCategory(value: "all", label: "All"),
ChipCategory(value: "coffee", label: "Coffee"),
ChipCategory(value: "lunch", label: "Lunch"),
ChipCategory(value: "dinner", label: "Dinner"),
ChipCategory(value: "bakery", label: "Bakery"),
ChipCategory(value: "bars", label: "Bars"),
ChipCategory(value: "desserts", label: "Desserts"),
]import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.adamglin.phosphoricons.regular.Coffee
import com.esuiss.ui.components.Chip
import com.esuiss.ui.components.ChipGroup
import com.esuiss.ui.components.Text
import com.esuiss.ui.components.TextVariantGroup multiple
Set multiple to let people select several chips.


import * as React from "react"
import { View } from "react-native"
import { Chip, ChipGroup } from "@/components/ui/chip"
import { Text } from "@/components/ui/text"
export default function ChipGroupMultiple() {
const [value, setValue] = React.useState(["coffee", "bakery"])
return (
<View className="gap-3">
<ChipGroup multiple value={value} onValueChange={setValue}>
<Chip value="coffee">Coffee</Chip>
<Chip value="lunch">Lunch</Chip>
<Chip value="dinner">Dinner</Chip>
<Chip value="bakery">Bakery</Chip>
<Chip value="bars">Bars</Chip>
<Chip value="desserts">Desserts</Chip>import * as React from "react"
import { View } from "react-native"
import { Chip, ChipGroup } from "@/components/ui/chip"
import { Text } from "@/components/ui/text"
export default function ChipGroupMultiple() {
const [value, setValue] = React.useState(["coffee", "bakery"])
return (
<View style={{ gap: 12 }}>
<ChipGroup multiple value={value} onValueChange={setValue}>
<Chip value="coffee">Coffee</Chip>
<Chip value="lunch">Lunch</Chip>
<Chip value="dinner">Dinner</Chip>
<Chip value="bakery">Bakery</Chip>
<Chip value="bars">Bars</Chip>
<Chip value="desserts">Desserts</Chip>import SwiftUI
struct ChipCategory: Hashable {
let value: String
let label: String
}
@MainActor let chipCategories = [
ChipCategory(value: "all", label: "All"),
ChipCategory(value: "coffee", label: "Coffee"),
ChipCategory(value: "lunch", label: "Lunch"),
ChipCategory(value: "dinner", label: "Dinner"),
ChipCategory(value: "bakery", label: "Bakery"),
ChipCategory(value: "bars", label: "Bars"),
ChipCategory(value: "desserts", label: "Desserts"),
]import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.adamglin.phosphoricons.regular.Coffee
import com.esuiss.ui.components.Chip
import com.esuiss.ui.components.ChipGroup
import com.esuiss.ui.components.Text
import com.esuiss.ui.components.TextVariantGroup uncontrolled
A group using defaultValue.
A group that starts with a selection.


import { Chip, ChipGroup } from "@/components/ui/chip"
export default function ChipGroupUncontrolled() {
return (
<ChipGroup multiple defaultValue={["lunch"]} size="sm">
<Chip value="coffee">Coffee</Chip>
<Chip value="lunch">Lunch</Chip>
<Chip value="dinner">Dinner</Chip>
<Chip value="bakery">Bakery</Chip>
<Chip value="bars">Bars</Chip>
<Chip value="desserts">Desserts</Chip>
</ChipGroup>
)
}import SwiftUI
struct ChipCategory: Hashable {
let value: String
let label: String
}
@MainActor let chipCategories = [
ChipCategory(value: "all", label: "All"),
ChipCategory(value: "coffee", label: "Coffee"),
ChipCategory(value: "lunch", label: "Lunch"),
ChipCategory(value: "dinner", label: "Dinner"),
ChipCategory(value: "bakery", label: "Bakery"),
ChipCategory(value: "bars", label: "Bars"),
ChipCategory(value: "desserts", label: "Desserts"),
]import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import com.adamglin.phosphoricons.regular.Coffee
import com.esuiss.ui.components.Chip
import com.esuiss.ui.components.ChipGroup
import com.esuiss.ui.components.ChipSize
val ChipCategories = listOf(
"all" to "All",
"coffee" to "Coffee",
"lunch" to "Lunch",
"dinner" to "Dinner",
"bakery" to "Bakery",Group scrollable
Set scrollable to lay the chips out in a single horizontal scrolling row.


import { View } from "react-native"
import { Chip, ChipGroup } from "@/components/ui/chip"
const categories = [
{ value: "all", label: "All" },
{ value: "coffee", label: "Coffee" },
{ value: "lunch", label: "Lunch" },
{ value: "dinner", label: "Dinner" },
{ value: "bakery", label: "Bakery" },
{ value: "bars", label: "Bars" },
{ value: "desserts", label: "Desserts" },
]
export default function ChipGroupScrollable() {
return (
<View className="-mx-4">import { View } from "react-native"
import { Chip, ChipGroup } from "@/components/ui/chip"
const categories = [
{ value: "all", label: "All" },
{ value: "coffee", label: "Coffee" },
{ value: "lunch", label: "Lunch" },
{ value: "dinner", label: "Dinner" },
{ value: "bakery", label: "Bakery" },
{ value: "bars", label: "Bars" },
{ value: "desserts", label: "Desserts" },
]
export default function ChipGroupScrollable() {
return (
<View style={{ marginHorizontal: -16 }}>import SwiftUI
struct ChipCategory: Hashable {
let value: String
let label: String
}
@MainActor let chipCategories = [
ChipCategory(value: "all", label: "All"),
ChipCategory(value: "coffee", label: "Coffee"),
ChipCategory(value: "lunch", label: "Lunch"),
ChipCategory(value: "dinner", label: "Dinner"),
ChipCategory(value: "bakery", label: "Bakery"),
ChipCategory(value: "bars", label: "Bars"),
ChipCategory(value: "desserts", label: "Desserts"),
]import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.layout
import androidx.compose.ui.unit.dp
import com.adamglin.phosphoricons.regular.Coffee
import com.esuiss.ui.components.Chip
import com.esuiss.ui.components.ChipGroup
val ChipCategories = listOf(
"all" to "All",
"coffee" to "Coffee",Group disabled
A disabled group.


import { Chip, ChipGroup } from "@/components/ui/chip"
export default function ChipGroupDisabled() {
return (
<ChipGroup disabled defaultValue={["coffee"]}>
<Chip value="coffee">Coffee</Chip>
<Chip value="lunch">Lunch</Chip>
<Chip value="dinner">Dinner</Chip>
</ChipGroup>
)
}import SwiftUI
struct ChipCategory: Hashable {
let value: String
let label: String
}
@MainActor let chipCategories = [
ChipCategory(value: "all", label: "All"),
ChipCategory(value: "coffee", label: "Coffee"),
ChipCategory(value: "lunch", label: "Lunch"),
ChipCategory(value: "dinner", label: "Dinner"),
ChipCategory(value: "bakery", label: "Bakery"),
ChipCategory(value: "bars", label: "Bars"),
ChipCategory(value: "desserts", label: "Desserts"),
]import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import com.adamglin.phosphoricons.regular.Coffee
import com.esuiss.ui.components.Chip
import com.esuiss.ui.components.ChipGroup
val ChipCategories = listOf(
"all" to "All",
"coffee" to "Coffee",
"lunch" to "Lunch",
"dinner" to "Dinner",
"bakery" to "Bakery",
"bars" to "Bars",Accessibility
- A chip has the
togglebuttonrole withcheckedstate, or theradiorole in a single-selection group. - A group has the
radiogrouprole for single selection andgroupfor multiple. - With
onRemove, the chip exposes aremoveaccessibility action, and the remove button has its ownbuttonrole and label.
API Reference
Chip
Selectable pill.
| Prop | Type | Default |
|---|---|---|
selected | boolean | - |
defaultSelected | boolean | - |
onSelectedChange | (selected: boolean, details) => void | - |
size | "default" | "sm" | "default" |
icon | PhosphorIcon | - |
onRemove | () => void | - |
removeLabel | string | "Remove" |
Also accepts the props of React.ComponentProps<typeof TogglePrimitive>, except pressed, defaultPressed and onPressedChange.
Use selected with onSelectedChange, or defaultSelected, on a standalone chip. Inside a group, give each chip a value; its size is then inherited from the group. icon is shown before the label, and removeLabel is the accessibility label of the remove button. While pressed the chip drops to opacity-80. chipVariants is also exported if you need the classes elsewhere.
ChipGroup
Manages selection and layout for several chips.
| Prop | Type | Default |
|---|---|---|
size | ChipSize | "default" |
scrollable | boolean | false |
Also accepts the props of React.ComponentProps<typeof ToggleGroupPrimitive>.
Control the group with value, defaultValue and onValueChange, which take arrays of values. scrollable shows the chips in a horizontal scroll view instead of wrapping them.
ChipSize
Values: .sm, .default.
ChipGroup
Manages selection and layout for several chips.
| Parameter | Type | Default |
|---|---|---|
selection | Binding<Value?> | - |
size | ChipSize: .sm | .default | .default |
scrollable | Bool | false |
content | () -> Content | - |
Chip
Selectable pill.
| Parameter | Type | Default |
|---|---|---|
isSelected | Binding<Bool>? | nil |
size | ChipSize?: .sm | .default | nil |
icon | Image? | nil |
onRemove | (() -> Void)? | nil |
label | () -> Label | - |
value | Value | - |
_ title | LocalizedStringKey | - |
Overloads: init(isSelected:size:icon:onRemove:label:), init(value:size:icon:onRemove:label:), init(_:isSelected:size:icon:onRemove:), init(_:value:size:icon:onRemove:).
ChipSize
Values: Default, Sm.
ChipGroup
Manages selection and layout for several chips.
| Parameter | Type | Default |
|---|---|---|
value | String? | - |
onValueChange | (String?) -> Unit | - |
modifier | Modifier | Modifier |
size | ChipSize: Default | Sm | ChipSize.Default |
scrollable | Boolean | false |
enabled | Boolean | true |
contentPadding | PaddingValues | PaddingValues(0.dp) |
content | @Composable () -> Unit | - |
values | Set<String> | - |
onValuesChange | (Set<String>) -> Unit | - |
Overloads: ChipGroup(value, onValueChange, content), ChipGroup(values, onValuesChange, content).
Chip
Selectable pill.
| Parameter | Type | Default |
|---|---|---|
text | String | - |
value | String | - |
modifier | Modifier | Modifier |
enabled | Boolean | true |
icon | ImageVector? | null |
onRemove | (() -> Unit)? | null |
removeLabel | String | "Remove $text" |
selected | Boolean | - |
onSelectedChange | (Boolean) -> Unit | - |
size | ChipSize: Default | Sm | LocalChipGroupState.current?.size ?: ChipSize.Default |
Overloads: Chip(text, value), Chip(text, selected, onSelectedChange, size).