Blossom UI

Cards

Card component with icon, title, description and footer, plus a product card with description, brand, reviews, discount, color and size options, out of stock state, horizontal layout, favorite toggle and add to cart button.

How to use it

Run npx @blossomui/react add card, or copy src/components/UI/Card/Card.tsx into your React project and import it.

import { Card, ProductCard } from './components/ui/Card'

Props

CardProps

PropTypeDescription
colorstringAccent color of this component: any CSS color. Without it the component uses `--blossom-accent`, which is pink by default.
title (required)string
descriptionReactNode
iconReactNodeIcon shown inside a tinted square.
footerReactNodeExtra content, for example buttons or links.
classNamestring

ProductCardLabels

PropTypeDescription
addToCart (required)string
added (required)string
unavailable (required)string
chooseSize (required)stringText of the button while a size is required and none is chosen.
outOfStock (required)string
addToFavorites (required)string
removeFromFavorites (required)string
expandPhoto (required)(name: string) => string
stars (required)(rating: number) => string
color (required)string
size (required)string
close (required)stringTexts of the photo viewer.
previousPhoto (required)string
nextPhoto (required)string
showPhoto (required)(photo: number) => string
viewer (required)(name: string, photo: number, total: number) => string

ProductColor

PropTypeDescription
value (required)stringAny CSS color.
labelstringName of the color, used by screen readers and passed to `onAddToCart`.

ProductSize

PropTypeDescription
value (required)stringWhat `onAddToCart` receives, for example "250 g".
labelstringText of the button. Without it the value is used.
pricenumberPrice of this size. Without it the price of the product is used.
originalPricenumberPrice before the discount of this size.
inStockbooleanSet it to false for a size that is not available.

ProductSelection

PropTypeDescription
colorstring
sizestring
pricenumberPrice of the product with the chosen size.

ProductCardProps

PropTypeDescription
labelsPartial<ProductCardLabels>Texts of the component. Pass only the ones you want to change, for example to translate it.
formatPrice(price: number) => stringFormats the prices, for example with `Intl.NumberFormat` to show another currency. Without it `currency` and two decimals are used.
colorstringAccent color of this component: any CSS color. Without it the component uses `--blossom-accent`, which is pink by default.
badgeColorstringColor of the badge: any CSS color. Without it the badge uses the accent.
preselectSizebooleanStart with the first size that is in stock chosen, so the price and `onAddToCart` already have a size.
requireSizebooleanThe add to cart button stays disabled until the user chooses a size.
buttonColorstringColor of the add to cart button: `accent` for the brand color or any CSS color. Without it the button is black, or white in dark mode.
image (required)string
name (required)string
price (required)number
descriptionstringShort text under the name. It is cut after two lines.
brandstringSmall text above the name, for example the brand or the category.
ratingnumberFrom 0 to 5.
reviewsnumberNumber of reviews, shown next to the stars.
badgestring
originalPricenumberPrice before the discount. It is crossed out and the percentage is calculated.
expandablebooleanOpens the photo in full size when it is pressed.
imagesstring[]More photos of the product. They are shown after the main image when it is expanded, with arrows and thumbnails.
currencystringSymbol shown before the prices.
colors(string | ProductColor)[]Available colors, a CSS color or an object with a `value` and a `label`. The user can choose one.
sizes(string | ProductSize)[]Available sizes or weights, a string or an object with its own `price`. The user can choose one and the price changes.
inStockbooleanOut of stock products cannot be added to the cart.
layout'vertical' | 'horizontal'`horizontal` puts the image at the left, useful for lists.
onAddToCart(name: string, selection: ProductSelection) => voidCalled with the product name and the chosen color and size when the user presses "Add to cart".
onFavoriteChange(favorite: boolean) => voidCalled when the user marks or unmarks the product as favorite.
classNamestring

Getting started

  • Introduction
  • Installation
  • Changelog

Customization

  • Colors
  • Brand color
  • Texts and translation

Components

  • Accordion
  • Alert dialog
  • Alerts
  • Avatar
  • Badges
  • Banner
  • Breadcrumb
  • Buttons
  • Calendar
  • Cards
  • Carousel
  • Charts
  • Chip input
  • Collapsible
  • Color picker
  • Combobox
  • Command palette
  • Context menu
  • Copy button
  • Date picker
  • Drawer
  • Dropdown
  • Empty state
  • File upload
  • Footer
  • Forms
  • Hover card
  • Jumbotron
  • KBD
  • Menubar
  • Modal
  • Navbar
  • Navigation menu
  • Number input
  • OTP input
  • Pagination
  • Popover
  • Pricing
  • Progress
  • Rating
  • Resizable panels
  • Scroll area
  • Segmented control
  • Separator
  • Sidebar
  • Skeleton
  • Slider
  • Spinners
  • Stats
  • Stepper
  • Survey
  • Table
  • Tabs
  • Time picker
  • Timeline
  • Timer button
  • Toasts
  • Tooltip
  • Transfer list
  • Tree