AspectRatio
Keeps a fixed aspect ratio for its content—images, video, iframes, maps—so nothing jumps while it loads. The ratio goes in data-ts-ratio; the direct child fills the box.
Layout · TaishoDS Core, in plain HTML.
Examples
One working example per case. Each example is the HTML of its preview—copy it as is, and with Core’s CSS and JS loaded, it looks and works the same.
16:9 video thumbnail
When to use
- You’re embedding media of unknown size and don’t want the layout to jump.
- Every piece in a grid has to have the same shape.
- It’s an embed (video, map) that needs a proportional box.
When not to use
- The image has a known fixed height, so you don’t need it.
- It’s text content. The text sets the height.
Do
- Choose the ratio based on the real content (16/9 for video, 1/1 for portraits).
- Combine it with
skeletonif the media takes a while to arrive.
Don’t
- Don’t use it to crop something that needs to be seen in full.
- Don’t add several children. The direct child is the one that fills the box.
TaishoDS Core
Needs Core’s JS, which hooks in through data-ts-* attributes.
The ratio is a continuous value. The stylesheet reads it from --ts-aspect-ratio, and Core writes that variable. Until Core runs, only 1 and 16/9 render correctly, because they also have their own class (ts aspect-square, aspect-video). Any other ratio renders square.
Core hooks into it through these attributes. They go in the markup, and there’s nothing to initialize.
data-ts-ratio
What it does: Pass the ratio in data-ts-ratio="1.3333" on the element. Core copies it to --ts-aspect-ratio on init and whenever the attribute changes. There’s no interaction—it only sets the value at rest.
From the CDN, without a build, load taisho.aspect-ratio.css along with taisho.base.css. That file is all you need.
For how Core works in general, see Behavior.
Accessibility
- A purely visual container. It adds no semantics and isn’t in the focus order.
Verification
What was actually tested. Anything that wasn’t tested says so—we’d rather say “not verified” than claim too much.
- axe WCAG 2.2 A + AA in a real browser, in light and dark mode, before every release.
- keyboard Adds no keys of its own—it uses the browser’s native behavior.
- screen reader Not verified with a screen reader. Test it in your own combination of components, not just here, where each one appears alone and on its happy path.