Skip to main content

useButtonStyles

Resolve the background, foreground, and disabled styles for a given button type from the active theme. This is the same helper the built-in Button, ActionButton, IconButton, and MenuButton components use internally — use it to build custom buttons that stay consistent with the library's theming.

Usage

import { AnimatedPressable, useButtonStyles } from '@multinaire/ui';
import { Typography } from '@multinaire/ui';

function MyButton({ type = 'primary', disabled, onPress, title }) {
const { style, foregroundColor, disabledStyle } = useButtonStyles(type);

return (
<AnimatedPressable
disabled={disabled}
style={[style, disabled && disabledStyle]}
onPress={onPress}
>
<Typography color={foregroundColor}>{title}</Typography>
</AnimatedPressable>
);
}

Parameters

ParameterTypeDescription
typeButtonTypeOne of 'primary', 'secondary', 'surface', 'success', 'warning', 'error'.

Return Value

PropertyTypeDescription
styleViewProps['style']Background color style for the given type (e.g. { backgroundColor: colors.primary }).
foregroundColorColorKeysThe matching foreground color key for content placed on the button (e.g. 'onPrimary', 'onBackground').
disabledStyleViewProps['style']Style applied when the button is disabled ({ opacity: 0.5 }).

Type → color mapping

typeBackgroundForeground
primarycolors.primaryonPrimary
secondarycolors.secondaryonSecondary
surfacecolors.backgroundVariantonBackground
successcolors.successonPrimary
warningcolors.warningonPrimary
errorcolors.erroronPrimary

Notes

  • Must be called inside a MultinaireUI.
  • Pair with usePressableInteraction to add hover/press feedback to your custom button.