Aspect Ratio
Keeps content at a fixed ratio using the CSS aspect-ratio property.
Installation
Shadwire follows shadcn/ui's open code model: the component's source is copied into your application and becomes yours. Install it with the CLI:
The aspect-ratio registry item installs these files:
-
app/components/ui_component.rb -
app/components/ui/aspect_ratio_component.rb -
app/helpers/ui/aspect_ratio_helper.rb -
vendor/shadwire/shadwire.css
Haven't installed the CLI yet? gem install shadwire, then shadwire init.
Usage
Examples
Default
Constrains the content to a 16 / 9 ratio.
16 / 9
API reference
Every part accepts class / class_name and **attrs.
| Component | Argument | Default | Description |
|---|---|---|---|
AspectRatio |
ratio |
1 |
Width over height: a number (16.0 / 9) or a string ("16 / 9"). |