import { Icon } from "@vortexlabs/vortex-native";
import type { IconSourceProps } from "@vortexlabs/vortex-native";
import Svg, { Path } from "react-native-svg";
type Props = IconSourceProps;
const Hexagon = (props: Props) => {
const { width, height, color } = props;
return (
<Svg width={width} height={height} color={color} viewBox="0 0 24 24">
<Path d="M12 2 21 7v10l-9 5-9-5V7z" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" />
</Svg>
);
};
<Icon
src={Hexagon}
size={4}
color="default"
/>Features
- Accepts an SVG element or component.
- Supports responsive sizes and colors.
- Scales with the system text size.
- Supports non-square icons with
autoWidth. - Mirrors directional icons in right-to-left layouts with
flipRTL.
SVG Source
Define a source with react-native-svg and pass it to src. Forward the supplied dimensions and color to Svg so the artwork follows the Icon settings.
import { Icon, type IconSourceProps } from "@vortexlabs/vortex-native";
import Svg, { Path } from "react-native-svg";
type Props = IconSourceProps;
const Hexagon = (props: Props) => {
const { width, height, color } = props;
return (
<Svg width={width} height={height} color={color} viewBox="0 0 24 24">
<Path
d="M12 2 21 7v10l-9 5-9-5V7z"
fill="none"
stroke="currentColor"
strokeWidth={2}
strokeLinecap="round"
strokeLinejoin="round"
/>
</Svg>
);
};
export const Example = () => <Icon src={Hexagon} />;Color
Use color to choose a foreground color. On a standalone Icon, color="inherit" resolves to the theme's default foreground. See Properties for all options.
<Stack direction="row" gap={2} wrap>
<Icon src={Hexagon} size={6} color="default" />
<Icon src={Hexagon} size={6} color="subtle" />
<Icon src={Hexagon} size={6} color="primary" />
<Icon src={Hexagon} size={6} color="success" />
<Icon src={Hexagon} size={6} color="warning" />
<Icon src={Hexagon} size={6} color="critical" />
</Stack>Inverse Color
Use color="inverse" on an inverse background.
<Stack width={48} align="center" backgroundColor="inverse" paddingBlock={2} borderRadius="sm">
<Icon src={Hexagon} size={6} color="inverse" />
</Stack>Responsive Colors
Use a breakpoint object to change the foreground color with the window width.
<Icon src={Hexagon} size={6} color={{ xs: "subtle", md: "primary" }} />Size
Set size in theme units. On the default theme, the default size={4} is 16pt before font scaling.
<Stack direction="row" align="center" gap={3} wrap>
<Icon src={Hexagon} size={4} />
<Icon src={Hexagon} size={6} />
<Icon src={Hexagon} size={8} />
<Icon src={Hexagon} size={12} />
</Stack>Responsive Sizes
Pass a breakpoint object to change the size with the window width.
<Icon src={Hexagon} size={{ xs: 4, md: 8 }} />System Font Scaling
Icons follow the system text size up to the theme's maxFontSizeMultiplier. Set allowFontScaling={false} when artwork needs a fixed size.
<Icon src={Hexagon} size={6} />
<Icon src={Hexagon} size={6} allowFontScaling={false} />Auto Width
Use autoWidth to fill a parent with a defined width while keeping the height from size. Turn off Auto Width in the props panel to see the default square frame.
import { Icon, Stack } from "@vortexlabs/vortex-native";
import type { IconSourceProps } from "@vortexlabs/vortex-native";
import Svg, { Path } from "react-native-svg";
type Props = IconSourceProps;
const WideBattery = (props: Props) => {
const { width, height, color } = props;
return (
<Svg width={width} height={height} color={color} viewBox="0 0 48 24">
<Path d="M7 5h31a3 3 0 0 1 3 3v8a3 3 0 0 1-3 3H7a3 3 0 0 1-3-3V8a3 3 0 0 1 3-3Zm38 4v6M10 9v6m6-6v6m6-6v6" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" />
</Svg>
);
};
export const Example = () => (
<Stack
width={80}
align="center"
>
<Icon src={WideBattery} size={10} autoWidth />
</Stack>
);Right-to-Left Layouts
Set flipRTL on directional icons that should mirror with the app's layout direction.
<Icon src={ArrowRight} flipRTL />Accessible Names
Label an icon when it conveys meaning on its own.
<Icon src={Heart} size={8} color="critical" ariaLabel="Favourite" />Accessibility
ariaLabel unset on a decorative icon or one that repeats a visible label.