A component that displays a short value that users can select or execute.
@seed-design/lynx-react@0.5.0, @seed-design/lynx-css@0.9.0
import "./styles" ;
import { Chip, useSeedClassName } from "@seed-design/lynx-react" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-chip-root` }>
< view className = "chip-preview" >
< view className = "chip-preview__row" >
< Chip.Button >
< Chip.Label >Button Chip</ Chip.Label >
</ Chip.Button >
< Chip.Toggle >
< Chip.Label >Toggle Chip</ Chip.Label >
</ Chip.Toggle >
</ view >
< Chip.RadioRoot defaultValue = "option1" >
< view className = "chip-preview__row" >
< Chip.RadioItem value = "option1" >
< Chip.Label >Radio Chip 1</ Chip.Label >
</ Chip.RadioItem >
< Chip.RadioItem value = "option2" >
< Chip.Label >Radio Chip 2</ Chip.Label >
</ Chip.RadioItem >
</ view >
</ Chip.RadioRoot >
</ view >
</ view >
);
}
npm install @seed-design/lynx-react @seed-design/lynx-css pnpm add @seed-design/lynx-react @seed-design/lynx-css yarn add @seed-design/lynx-react @seed-design/lynx-css bun add @seed-design/lynx-react @seed-design/lynx-css
style?CSSProperties | undefined
children?React.ReactNode
className?string | undefined
bindtap?EventHandler < BaseTouchEvent < Target >> | undefined
main-thread:bindtap?EventHandler < BaseTouchEvent < Element >> | undefined
checked?boolean | undefined
defaultChecked?boolean | undefined
onCheckedChange?(( checked : boolean ) => void ) | undefined
style?CSSProperties | undefined
children?React.ReactNode
className?string | undefined
bindtap?EventHandler < BaseTouchEvent < Target >> | undefined
main-thread:bindtap?EventHandler < BaseTouchEvent < Element >> | undefined
value?string | undefined
defaultValue?string | undefined
disabled?boolean | undefined
onValueChange?(( value : string ) => void ) | undefined
style?CSSProperties | undefined
children?React.ReactNode
className?string | undefined
valuestring
style?CSSProperties | undefined
children?React.ReactNode
className?string | undefined
bindtap?EventHandler < BaseTouchEvent < Target >> | undefined
main-thread:bindtap?EventHandler < BaseTouchEvent < Element >> | undefined
style?CSSProperties | undefined
children?React.ReactNode
className?string | undefined
import "./styles" ;
import { Chip, useSeedClassName } from "@seed-design/lynx-react" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-chip-root` }>
< view className = "chip-preview" >
< view className = "chip-preview__row" >
< Chip.Button size = "small" >
< Chip.Label >Small Button</ Chip.Label >
</ Chip.Button >
< Chip.Toggle size = "small" >
< Chip.Label >Small Toggle</ Chip.Label >
</ Chip.Toggle >
</ view >
< Chip.RadioRoot defaultValue = "option1" >
< view className = "chip-preview__row" >
< Chip.RadioItem value = "option1" size = "small" >
< Chip.Label >Small Radio 1</ Chip.Label >
</ Chip.RadioItem >
< Chip.RadioItem value = "option2" size = "small" >
< Chip.Label >Small Radio 2</ Chip.Label >
</ Chip.RadioItem >
</ view >
</ Chip.RadioRoot >
</ view >
</ view >
);
}
import "./styles" ;
import { Chip, useSeedClassName } from "@seed-design/lynx-react" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-chip-root` }>
< view className = "chip-preview" >
< view className = "chip-preview__row" >
< Chip.Button size = "medium" >
< Chip.Label >Medium Button</ Chip.Label >
</ Chip.Button >
< Chip.Toggle size = "medium" >
< Chip.Label >Medium Toggle</ Chip.Label >
</ Chip.Toggle >
</ view >
< Chip.RadioRoot defaultValue = "option1" >
< view className = "chip-preview__row" >
< Chip.RadioItem value = "option1" size = "medium" >
< Chip.Label >Medium Radio 1</ Chip.Label >
</ Chip.RadioItem >
< Chip.RadioItem value = "option2" size = "medium" >
< Chip.Label >Medium Radio 2</ Chip.Label >
</ Chip.RadioItem >
</ view >
</ Chip.RadioRoot >
</ view >
</ view >
);
}
import "./styles" ;
import { Chip, useSeedClassName } from "@seed-design/lynx-react" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-chip-root` }>
< view className = "chip-preview" >
< view className = "chip-preview__row" >
< Chip.Button size = "large" >
< Chip.Label >Large Button</ Chip.Label >
</ Chip.Button >
< Chip.Toggle size = "large" >
< Chip.Label >Large Toggle</ Chip.Label >
</ Chip.Toggle >
</ view >
< Chip.RadioRoot defaultValue = "option1" >
< view className = "chip-preview__row" >
< Chip.RadioItem value = "option1" size = "large" >
< Chip.Label >Large Radio 1</ Chip.Label >
</ Chip.RadioItem >
< Chip.RadioItem value = "option2" size = "large" >
< Chip.Label >Large Radio 2</ Chip.Label >
</ Chip.RadioItem >
</ view >
</ Chip.RadioRoot >
</ view >
</ view >
);
}
import "./styles" ;
import { Chip, useSeedClassName } from "@seed-design/lynx-react" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-chip-root` }>
< view className = "chip-preview" >
< view className = "chip-preview__row" >
< Chip.Button variant = "solid" >
< Chip.Label >Solid Button</ Chip.Label >
</ Chip.Button >
< Chip.Toggle variant = "solid" >
< Chip.Label >Solid Toggle</ Chip.Label >
</ Chip.Toggle >
</ view >
< Chip.RadioRoot defaultValue = "option1" >
< view className = "chip-preview__row" >
< Chip.RadioItem value = "option1" variant = "solid" >
< Chip.Label >Solid Radio 1</ Chip.Label >
</ Chip.RadioItem >
< Chip.RadioItem value = "option2" variant = "solid" >
< Chip.Label >Solid Radio 2</ Chip.Label >
</ Chip.RadioItem >
</ view >
</ Chip.RadioRoot >
</ view >
</ view >
);
}
import "./styles" ;
import { Chip, useSeedClassName } from "@seed-design/lynx-react" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-chip-root` }>
< view className = "chip-preview" >
< view className = "chip-preview__row" >
< Chip.Button variant = "outlineStrong" >
< Chip.Label >Outline Strong Button</ Chip.Label >
</ Chip.Button >
< Chip.Toggle variant = "outlineStrong" >
< Chip.Label >Outline Strong Toggle</ Chip.Label >
</ Chip.Toggle >
</ view >
< Chip.RadioRoot defaultValue = "option1" >
< view className = "chip-preview__row" >
< Chip.RadioItem value = "option1" variant = "outlineStrong" >
< Chip.Label >Outline Strong Radio 1</ Chip.Label >
</ Chip.RadioItem >
< Chip.RadioItem value = "option2" variant = "outlineStrong" >
< Chip.Label >Outline Strong Radio 2</ Chip.Label >
</ Chip.RadioItem >
</ view >
</ Chip.RadioRoot >
</ view >
</ view >
);
}
import "./styles" ;
import { Chip, useSeedClassName } from "@seed-design/lynx-react" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-chip-root` }>
< view className = "chip-preview" >
< view className = "chip-preview__row" >
< Chip.Button variant = "outlineWeak" >
< Chip.Label >Outline Weak Button</ Chip.Label >
</ Chip.Button >
< Chip.Toggle variant = "outlineWeak" >
< Chip.Label >Outline Weak Toggle</ Chip.Label >
</ Chip.Toggle >
</ view >
< Chip.RadioRoot defaultValue = "option1" >
< view className = "chip-preview__row" >
< Chip.RadioItem value = "option1" variant = "outlineWeak" >
< Chip.Label >Outline Weak Radio 1</ Chip.Label >
</ Chip.RadioItem >
< Chip.RadioItem value = "option2" variant = "outlineWeak" >
< Chip.Label >Outline Weak Radio 2</ Chip.Label >
</ Chip.RadioItem >
</ view >
</ Chip.RadioRoot >
</ view >
</ view >
);
}
import "./styles" ;
import IconHeartFill from "@karrotmarket/lynx-monochrome-icon/IconHeartFill" ;
import { Chip, useSeedClassName } from "@seed-design/lynx-react" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-chip-root` }>
< view className = "chip-preview" >
< view className = "chip-preview__row" >
< Chip.Button >
< Chip.PrefixIcon icon = {< IconHeartFill />} />
< Chip.Label >With Icon Button</ Chip.Label >
</ Chip.Button >
< Chip.Toggle >
< Chip.PrefixIcon icon = {< IconHeartFill />} />
< Chip.Label >With Icon Toggle</ Chip.Label >
</ Chip.Toggle >
</ view >
< Chip.RadioRoot defaultValue = "option1" >
< view className = "chip-preview__row" >
< Chip.RadioItem value = "option1" >
< Chip.PrefixIcon icon = {< IconHeartFill />} />
< Chip.Label >With Icon Radio 1</ Chip.Label >
</ Chip.RadioItem >
< Chip.RadioItem value = "option2" >
< Chip.PrefixIcon icon = {< IconHeartFill />} />
< Chip.Label >With Icon Radio 2</ Chip.Label >
</ Chip.RadioItem >
</ view >
</ Chip.RadioRoot >
</ view >
</ view >
);
}
import "./styles" ;
import IconChevronDownLine from "@karrotmarket/lynx-monochrome-icon/IconChevronDownLine" ;
import { Chip, useSeedClassName } from "@seed-design/lynx-react" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-chip-root` }>
< view className = "chip-preview" >
< view className = "chip-preview__row" >
< Chip.Button >
< Chip.Label >Button with Suffix</ Chip.Label >
< Chip.SuffixIcon icon = {< IconChevronDownLine />} />
</ Chip.Button >
< Chip.Toggle >
< Chip.Label >Toggle with Suffix</ Chip.Label >
< Chip.SuffixIcon icon = {< IconChevronDownLine />} />
</ Chip.Toggle >
</ view >
< Chip.RadioRoot defaultValue = "option1" >
< view className = "chip-preview__row" >
< Chip.RadioItem value = "option1" >
< Chip.Label >Radio with Suffix 1</ Chip.Label >
< Chip.SuffixIcon icon = {< IconChevronDownLine />} />
</ Chip.RadioItem >
< Chip.RadioItem value = "option2" >
< Chip.Label >Radio with Suffix 2</ Chip.Label >
< Chip.SuffixIcon icon = {< IconChevronDownLine />} />
</ Chip.RadioItem >
</ view >
</ Chip.RadioRoot >
</ view >
</ view >
);
}
With layout="iconOnly", pass both Icon as a child and accessibility-label.
import "./styles" ;
import IconArrowClockwiseCircularLine from "@karrotmarket/lynx-monochrome-icon/IconArrowClockwiseCircularLine" ;
import IconBellLine from "@karrotmarket/lynx-monochrome-icon/IconBellLine" ;
import IconBellSlashLine from "@karrotmarket/lynx-monochrome-icon/IconBellSlashLine" ;
import IconTimer_10Line from "@karrotmarket/lynx-monochrome-icon/IconTimer_10Line" ;
import IconTimer_3Line from "@karrotmarket/lynx-monochrome-icon/IconTimer_3Line" ;
import { useState } from "@lynx-js/react" ;
import { Chip, Icon, useSeedClassName } from "@seed-design/lynx-react" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
const [ checked , setChecked ] = useState ( false );
return (
< view className = { `${ seedClassName } docs-lynx-chip-root` }>
< view className = "chip-preview" >
< view className = "chip-preview__row" >
< Chip.Button layout = "iconOnly" accessibility-label = "Refresh" >
< Icon icon = {< IconArrowClockwiseCircularLine />} />
</ Chip.Button >
< Chip.Toggle
layout = "iconOnly"
checked = {checked}
onCheckedChange = {setChecked}
accessibility-label = "Receive notifications"
>
< Icon icon = {checked ? < IconBellLine /> : < IconBellSlashLine />} />
</ Chip.Toggle >
</ view >
< Chip.RadioRoot defaultValue = "3" >
< view className = "chip-preview__row" >
< Chip.RadioItem value = "3" layout = "iconOnly" accessibility-label = "3 seconds" >
< Icon icon = {< IconTimer_3Line />} />
</ Chip.RadioItem >
< Chip.RadioItem value = "10" layout = "iconOnly" accessibility-label = "10 seconds" >
< Icon icon = {< IconTimer_10Line />} />
</ Chip.RadioItem >
</ view >
</ Chip.RadioRoot >
</ view >
</ view >
);
}
The Lynx package does not provide an Avatar component. Use the Chip.PrefixAvatar slot by putting your app's own avatar component or view inside it. The initial circle in the example below is not an Avatar implementation including image loading and fallback, but only shows how to combine slots.
import "./styles" ;
import { Chip, useSeedClassName } from "@seed-design/lynx-react" ;
function AppAvatar () {
return (
< view className = "chip-preview__avatar" >
< text className = "chip-preview__avatar-label" >A</ text >
</ view >
);
}
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
return (
< view className = { `${ seedClassName } docs-lynx-chip-root` }>
< view className = "chip-preview" >
< view className = "chip-preview__row" >
< Chip.Button >
< Chip.PrefixAvatar >
< AppAvatar />
</ Chip.PrefixAvatar >
< Chip.Label >With Avatar Button</ Chip.Label >
</ Chip.Button >
< Chip.Toggle >
< Chip.PrefixAvatar >
< AppAvatar />
</ Chip.PrefixAvatar >
< Chip.Label >With Avatar Toggle</ Chip.Label >
</ Chip.Toggle >
</ view >
< Chip.RadioRoot defaultValue = "option1" >
< view className = "chip-preview__row" >
< Chip.RadioItem value = "option1" >
< Chip.PrefixAvatar >
< AppAvatar />
</ Chip.PrefixAvatar >
< Chip.Label >With Avatar Radio 1</ Chip.Label >
</ Chip.RadioItem >
< Chip.RadioItem value = "option2" >
< Chip.PrefixAvatar >
< AppAvatar />
</ Chip.PrefixAvatar >
< Chip.Label >With Avatar Radio 2</ Chip.Label >
</ Chip.RadioItem >
</ view >
</ Chip.RadioRoot >
</ view >
</ view >
);
}
Chip.Toggle
You can detect toggle state changes with onCheckedChange.
Chip.RadioRoot / Chip.RadioItem
You can detect radio button value changes with onValueChange of Chip.RadioRoot.
import "./styles" ;
import { useState } from "@lynx-js/react" ;
import { Chip, useSeedClassName } from "@seed-design/lynx-react" ;
export default function Example () {
const seedClassName = useSeedClassName ({ colorMode: "system" });
const [ toggleCount , setToggleCount ] = useState ( 0 );
const [ toggleLastValue , setToggleLastValue ] = useState < boolean | null >( null );
const [ radioCount , setRadioCount ] = useState ( 0 );
const [ radioLastValue , setRadioLastValue ] = useState < string | null >( null );
return (
< view className = { `${ seedClassName } docs-lynx-chip-root` }>
< view className = "chip-preview" >
< view className = "chip-preview__group" >
< Chip.Toggle
onCheckedChange = {( checked ) => {
setToggleCount (( previous ) => previous + 1 );
setToggleLastValue (checked);
}}
>
< Chip.Label >Toggle Chip</ Chip.Label >
</ Chip.Toggle >
< text className = "chip-preview__status" >
onCheckedChange called: {toggleCount} times, last value:{ " " }
{toggleLastValue === null ? "-" : JSON . stringify (toggleLastValue)}
</ text >
</ view >
< view className = "chip-preview__group" >
< Chip.RadioRoot
defaultValue = "option1"
onValueChange = {( value ) => {
setRadioCount (( previous ) => previous + 1 );
setRadioLastValue (value);
}}
>
< view className = "chip-preview__row" >
< Chip.RadioItem value = "option1" >
< Chip.Label >Radio 1</ Chip.Label >
</ Chip.RadioItem >
< Chip.RadioItem value = "option2" >
< Chip.Label >Radio 2</ Chip.Label >
</ Chip.RadioItem >
</ view >
</ Chip.RadioRoot >
< text className = "chip-preview__status" >
onValueChange called: {radioCount} times, last value: {radioLastValue ?? "-" }
</ text >
</ view >
</ view >
</ view >
);
}
Lynx Chip uses the same Button, Toggle, Radio composition and size/variant names as React Chip, but has the following differences:
Rendering elements : Native <view> / <text> are rendered instead of HTML <button> / <label> / <input>.
Event handling : bindtap is used instead of onClick, and onCheckedChange or onValueChange is used instead of onChange.
State styling : Instead of web pseudo selectors, touch state and selected state are connected to the pressed and selected variants of the Lynx recipe.
Icon rendering : Lynx monochrome icon and <image tint-color>-based Icon wrapper are used instead of SVG currentColor.
Accessibility role and state : Chip.Button, Chip.Toggle, and Chip.RadioItem pass their respective button, toggle, and radio roles via accessibility-role-description. Toggle's checked state and RadioItem's selected state are passed via accessibility-value, and disabled state is passed via accessibility-traits. You can override each property directly if needed.
Public surface : The Lynx package API directly provides the role of React's registry wrapper, so no separate snippet installation is needed.
The following features are not supported due to differences in the current Lynx implementation and runtime model.
Feature Description HiddenInput / inputProps Lynx has no HTML input and form submission model. name / required / native form valueThere is no target to connect HTML form attributes. raw DOM onChange Replaced with onCheckedChange or onValueChange. Keyboard focus / focusVisible Lynx has no keyboard focus model like the web. asChildLynx does not support web Slot-based polymorphic rendering. Avatar package Use by putting your app's own avatar view or component in the Chip.PrefixAvatar slot.