Skip to content

Button

The Button component is an interactive button that provides multiple visual variants, configurable sizes, and states like loading and disabled. It supports icons and smooth animations.

import { Button } from '@space-uy/pulsar-ui';
<Button text="Press me" onPress={() => console.log('Button pressed!')} />
PropertyTypeRequiredDefault valueDescription
textstring-The text to display on the button
onPress() => void-Function executed when the button is pressed
variant'flat' | 'outline' | 'transparent' | 'destructive''flat'Visual variant of the button
size'small' | 'medium' | 'large''large'Size of the button
loadingbooleanfalseShows loading indicator and disables the button
disabledbooleanfalseDisables the button and reduces its opacity
iconNameIconName-Lucide React Native icon name
styleStyleProp<ViewStyle>-Custom styles for the button container

Solid button with primary background color.

<Button text="Flat Button" variant="flat" />

Button with border and transparent background.

<Button text="Outline Button" variant="outline" />

Completely transparent button, ideal for secondary actions.

<Button text="Transparent Button" variant="transparent" />

Button for destructive actions with warning color.

<Button text="Delete" variant="destructive" />

Compact button for tight spaces.

<Button text="Small" size="small" />

Medium size, balanced between space and visibility.

<Button text="Medium" size="medium" />

Large button for primary actions.

<Button text="Large" size="large" />

Shows loading indicator and disables interactions.

<Button text="Loading" loading={true} />

Disables the button and reduces its opacity.

<Button text="Disabled" disabled={true} />

You can add icons from the Lucide React Native library:

<Button
text="Download"
iconName="Download"
onPress={() => startDownload()}
/>
<Button
text="Share"
iconName="Share"
variant="outline"
onPress={() => shareContent()}
/>
import { useState } from 'react';
import { Button } from '@space-uy/pulsar-ui';
function MyComponent() {
const [loading, setLoading] = useState(false);
const handleSubmit = async () => {
setLoading(true);
try {
await submitForm();
} finally {
setLoading(false);
}
};
return <Button text="Submit" loading={loading} onPress={handleSubmit} />;
}
<Button
text="Save Changes"
variant="flat"
size="medium"
iconName="Save"
style={{ marginTop: 20 }}
onPress={handleSave}
/>
  • The button includes smooth animations for hover and pressed states
  • On web platforms, pressed animations are handled with hover
  • Button text automatically uses typographic variants based on size
  • Icons always appear to the left of the text
  • During loading state, the icon is replaced by a loading indicator
  • The button is fully keyboard accessible
  • Disabled and loading states prevent inappropriate interactions
  • Colors respect contrast ratios defined in the theme