ReScript Shadcn
Get started
  • Installation
Components
  • Accordion
  • Alert
  • AlertDialog
  • AspectRatio
  • Attachment
  • Avatar
  • Badge
  • Breadcrumb
  • Bubble
  • Button
  • ButtonGroup
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Collapsible
  • Combobox
  • Command
  • ContextMenu
  • DataTable
  • DatePicker
  • Dialog
  • Direction
  • Drawer
  • DropdownMenu
  • Empty
  • Field
  • HoverCard
  • Input
  • InputGroup
  • InputOtp
  • Item
  • Kbd
  • Label
  • Marker
  • Menubar
  • Message
  • MessageScroller
  • NativeSelect
  • NavigationMenu
  • Pagination
  • Popover
  • Progress
  • RadioGroup
  • Resizable
  • ScrollArea
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Sonner
  • Spinner
  • Switch
  • Table
  • Tabs
  • Textarea
  • Toast
  • Toggle
  • ToggleGroup
  • Tooltip
  • Typography

Aspect Ratio

Displays content within a desired ratio.

Photo

Installation#

npx shadcn@latest add @rescript-shadcn/AspectRatio

Usage#

<AspectRatio ratio={16. / 9.} className="bg-muted rounded-lg">
  <Next.Image src="..." alt="Image" className="rounded-md object-cover" />
</AspectRatio>

Examples#

Square#

A square aspect ratio component using the ratio={1 / 1} prop. This is useful for displaying images in a square format.

Photo

Portrait#

A portrait aspect ratio component using the ratio={9 / 16} prop. This is useful for displaying images in a portrait format.

Photo

API Reference#

AspectRatio#

The AspectRatio component displays content within a desired ratio.

PropTypeDefaultRequired
ratiofloat-Yes
classNamestring-No

For more information, see the Base UI documentation.

module NextImage = {
  type props = {
    src: string,
module NextImage = {
  type props = {
    src: string,
module NextImage = {
  type props = {
    src: string,