Shared icon selection with responsive native colors
One.UI.Icon picks the icon element your app provides for the current
platform and colors it with a native system color.
One.iOS.Image.One.Android.Icon.Pass one element per platform. An icon without an accessibility label is treated as decoration.
import { One } from 'one'
const shareIcons = { ios: ( <One.iOS.Image systemName="square.and.arrow.up" accessibilityLabel="Share" swiftStyle={{ fontSize: 20 }} /> ), android: <One.Android.Icon name="share" size={20} accessibilityLabel="Share" />, web: <ShareIcon color="$color" size={20} />,}
<One.UI.Icon icons={shareIcons} colorRole="accent" /><One.UI.Icon icons={shareIcons} color="#E5484D" />| Props | Type | Description |
|---|---|---|
icons (required)IconElementsThe element for each platform. See below. | IconElements | The element for each platform. See below. |
colorRoleIconColorRole = "primary"A native system color. Cannot be set with color. | IconColorRole = "primary" | A native system color. Cannot be set with color. |
colorColorValueA fixed color, including an iOS dynamic color. Cannot be set with colorRole. | ColorValue | A fixed color, including an iOS dynamic color. Cannot be set with colorRole. |
| IconElements | Type | Description |
|---|---|---|
iosReactElement<ImageProps>A One.iOS.Image element. Anything else throws on iOS. | ReactElement<ImageProps> | A One.iOS.Image element. Anything else throws on iOS. |
androidReactElement<ComposeIconProps>A One.Android.Icon element. Anything else throws on Android. | ReactElement<ComposeIconProps> | A One.Android.Icon element. Anything else throws on Android. |
webReactElementReturned unchanged on web. Without it, web renders nothing. | ReactElement | Returned unchanged on web. Without it, web renders nothing. |
IconColorRole is "primary" | "secondary" | "tertiary" | "accent" | "danger".
swiftStyle.fontSize sets both
dimensions unless swiftStyle.width or swiftStyle.height supplies that
dimension. Numeric style.width and style.height override the corresponding
frame dimensions. The same frame reaches React Native and SwiftUI.size, 24 by default.| iOS | Android | Web | |
|---|---|---|---|
| Element | One.iOS.Image | One.Android.Icon | icons.web |
| Glyphs | SF Symbols | Material Symbols | Your own |
colorRole | SwiftUI system color | Material color scheme | Ignored |
Edit this page on GitHub.