You are looking at the documentation of the work in progress Hope UI 1.0, examples and information may be broken or outdated.

Buttons

IconButton

A button with an icon.

Import

tsx
import { IconButton } from "@hope-ui/core";
tsx
import { IconButton } from "@hope-ui/core";

Usage

tsx
<IconButton aria-label="Search">
<SearchIcon />
</IconButton>
tsx
<IconButton aria-label="Search">
<SearchIcon />
</IconButton>

If you want to create your own icon components check out Hope UI Icon documentation.

Variants

Use the variant prop to change the visual style of the IconButton.

tsx
<HStack spacing={4}>
<IconButton aria-label="Search" variant="default">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="solid">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="soft">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="outlined">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="plain">
<SearchIcon />
</IconButton>
</HStack>
tsx
<HStack spacing={4}>
<IconButton aria-label="Search" variant="default">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="solid">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="soft">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="outlined">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="plain">
<SearchIcon />
</IconButton>
</HStack>

Colors

The colorScheme prop allows changing the color of the IconButton.

tsx
<HStack spacing={4}>
<IconButton aria-label="Search" variant="solid" colorScheme="primary">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="solid" colorScheme="neutral">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="solid" colorScheme="success">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="solid" colorScheme="info">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="solid" colorScheme="warning">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="solid" colorScheme="danger">
<SearchIcon />
</IconButton>
</HStack>
tsx
<HStack spacing={4}>
<IconButton aria-label="Search" variant="solid" colorScheme="primary">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="solid" colorScheme="neutral">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="solid" colorScheme="success">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="solid" colorScheme="info">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="solid" colorScheme="warning">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" variant="solid" colorScheme="danger">
<SearchIcon />
</IconButton>
</HStack>
The colorScheme prop is ignored when the variant is set to default.

Sizes

Use the size prop to change the size of the IconButton.

tsx
<HStack spacing={4}>
<IconButton aria-label="Search" size="xs">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" size="sm">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" size="md">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" size="lg">
<SearchIcon />
</IconButton>
</HStack>
tsx
<HStack spacing={4}>
<IconButton aria-label="Search" size="xs">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" size="sm">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" size="md">
<SearchIcon />
</IconButton>
<IconButton aria-label="Search" size="lg">
<SearchIcon />
</IconButton>
</HStack>

Loading state

Pass the isLoading prop to show its loading state.

tsx
<IconButton aria-label="Search" isLoading>
<SearchIcon />
</IconButton>
tsx
<IconButton aria-label="Search" isLoading>
<SearchIcon />
</IconButton>

You can also change the loader element with the loader prop.

tsx
<IconButton aria-label="Search" isLoading loader={<BeatLoaderIcon boxSize={6} />}>
<SearchIcon />
</IconButton>
tsx
<IconButton aria-label="Search" isLoading loader={<BeatLoaderIcon boxSize={6} />}>
<SearchIcon />
</IconButton>

Theming

IconButton renders a Button and uses Button's theming API.

Props

NameTypeDescriptionDefault value
aria-label*stringA label that describes the button.
variant"default" | "solid" | "soft" | "outlined" | "plain"The visual style of the button.default
colorScheme"primary" | "neutral" | "success" | "info" | "warning" | "danger"The color of the button.primary
size"xs" | "sm" | "md" | "lg"The size of the button.md
isDisabledbooleanWhether the button should be disabled.
isLoadingbooleanWhether the button is in a loading state.
loaderJSX.ElementReplace the loader component when isLoading is true.
childrenJSX.ElementThe icon of the button.
Previous
Button