@bacon-pos/ui
v0.25.2
Published
Bacon POS design system — React Native component library
Maintainers
Readme
@bacon-pos/ui
Bacon POS design system — a scalable React Native component library, built from the Figma design system and published to npm. Works with Expo (SDK 53+) and bare React Native.
- Zero-config for consumers — ships compiled JS + type definitions. No babel or metro changes required in the app.
- Token-driven — colors, typography, spacing and radii come straight from Figma. Components read semantic tokens, so light/dark and custom brand themes just work.
- Versioned with changesets — every added component ships as a new semver release.
Installation (in the app)
npx expo install @bacon-pos/ui react-native-svg
# peer deps react + react-native are already in an Expo appRequires the New Architecture (default in Expo SDK 53). The
Inputfocus ring uses RN'sboxShadow(colored spread), which renders on iOS, Android and web only under the New Architecture. Border colors still work everywhere.
Wrap your app in the ThemeProvider once:
import { ThemeProvider } from '@bacon-pos/ui';
export default function App() {
return (
<ThemeProvider mode="light">
{/* ...your navigation / screens */}
</ThemeProvider>
);
}Use components anywhere below it:
import { Button, Text, Icon } from '@bacon-pos/ui';
<Text variant="h2" weight="semibold">Checkout</Text>
<Button label="Place order" variant="default" onPress={pay} />
<Button
label="Search"
variant="secondary"
leftIcon={<Icon name="search" size={20} />}
/>
// Icon on top — only for shape="square"
<Button
label="Make a sale"
shape="square"
topIcon={<Icon name="plus" size={24} color="#121416" />}
/>Button and LinkButton accept leftIcon / rightIcon. The square Button
additionally accepts topIcon (vertical stack). IconButton is icon-only.
Icons
Icons are themeable SVGs (react-native-svg). Tint with color (a text token
or any color string) and size with size:
<Icon name="check" size={24} color="#008C57" />
<Icon name="trash" color="secondary" />Adding icons — export the SVG from Figma, drop it into assets/icons/<kebab-name>.svg,
then run:
pnpm gen:iconsThis regenerates src/components/Icon/icons.generated.ts and the IconName
union (autocomplete). Each icon is stored as a normalized SVG string and rendered
via react-native-svg's SvgXml, so stroke icons, compound fills and circles
all render faithfully; colors are rewritten to currentColor so color tints them.
Multicolor brand assets (card logos, flags) live separately as Logo and
Flag. They are pre-compiled to real react-native-svg components with SVGR
(assets/graphics/ → pnpm gen:graphics), because gradients / clip-paths /
masks don't render reliably through runtime SvgXml. Their brand colors are
preserved (not tinted).
Fonts (Inter)
The type scale uses Inter. Load it in the app (fonts can't be bundled from a library reliably); if not loaded, RN falls back to the system font.
npx expo install @expo-google-fonts/inter expo-fontimport {
useFonts,
Inter_400Regular,
Inter_500Medium,
Inter_600SemiBold,
} from '@expo-google-fonts/inter';
const [loaded] = useFonts({
'Inter-Regular': Inter_400Regular,
'Inter-Medium': Inter_500Medium,
'Inter-SemiBold': Inter_600SemiBold,
});Theming
Access the active theme anywhere with useTheme():
import { useTheme } from '@bacon-pos/ui';
const theme = useTheme();
// theme.colors.brand.primary, theme.spacing.lg, theme.radii.md, ...Custom brand theme:
import { ThemeProvider, lightTheme, type Theme } from '@bacon-pos/ui';
const brand: Theme = {
...lightTheme,
colors: { ...lightTheme.colors, brand: { ...lightTheme.colors.brand, primary: '#123456' } },
};
<ThemeProvider theme={brand}>{children}</ThemeProvider>;Exposed tokens: palette, typography, fontFamily, fontWeight, spacing,
radii, space(n), lightTheme, darkTheme, textStyle(theme, variant, weight).
Typography (global by default, overridable)
The Figma type scale (Inter — Display / H1–H3 / Body / Caption) ships in the theme, so every component uses it automatically. You don't wire anything up.
Override it in one place with overrides (deep-merged onto the base theme,
applies to every current and future component):
<ThemeProvider
overrides={{
fontFamily: { regular: 'Poppins-Regular', medium: 'Poppins-Medium' },
typography: { h1: { fontSize: 30, lineHeight: 38 } },
}}
>
{children}
</ThemeProvider>Override for a single instance with the style prop:
<Text variant="h1" style={{ fontSize: 28, letterSpacing: 0.5 }}>Title</Text>Building a component that renders text without <Text>? Use the helper so it
honors global overrides too:
import { useTheme, textStyle } from '@bacon-pos/ui';
const theme = useTheme();
const style = textStyle(theme, 'bodyMedium', 'medium'); // full TextStyleLocal development
pnpm install
pnpm storybook # component explorer at http://localhost:6006
pnpm test # unit tests (Jest + RN Testing Library)
pnpm typecheck # tsc --noEmit
pnpm build # compile to lib/ via react-native-builder-bobAdding a component
- Create
src/components/<Name>/with<Name>.tsx,<Name>.stories.tsx,<Name>.test.tsx, andindex.ts. - Read tokens from
useTheme()— never hardcode colors or spacing. - Re-export it from
src/components/index.ts. - Add a changeset (see below).
Releasing a new version
- Record what changed:
Choose patch (fixes), minor (new components / props) or major (breaking changes) and write a summary.pnpm changeset - Apply the version bump + changelog:
pnpm version - Publish to npm (requires
npm loginor anNPM_TOKEN):pnpm release
Never commit npm tokens. Use
npm login, or setNPM_TOKENas an environment variable / CI secret..npmrcis gitignored.
Roadmap
Built from the Figma design system (colors, typography, ~150 icons, inputs,
etc.). Current components: Button, IconButton, LinkButton, Input, Card,
ProductCard, Surface, Text, Icon (167 icons — 24px outline + fill + 20px
optical set), plus multicolor Logo (Visa/Mastercard) and Flag (US/BR) brand
assets, QuantityStepper, CodeInput (PIN), CodeField (segmented code),
Spinner, Chip + ChipGroup (single/multi select), Avatar (photo or
initials), and form controls Checkbox, Radio, Switch (each standalone or
with a positionable label). The Figma
"loader" is an animated ring, not an icon — use RN's ActivityIndicator
(Button/LinkButton already do).
