Wrapper (is--wrapper)
is--wrapper is a class that collectively controls the width of its direct child content.
CSS
.is--wrapper {
// 子要素の制御
--contentSize: var(--sz--m, 100%);
> * {
inline-size: 100%; // l--stack 等の縦並び配下で自然幅要素のガタつきを防ぐ
max-inline-size: min(100%, var(--contentSize)); // min ないとimg要素等がはみ出す
margin-inline: auto;
}
}
// Memo: それぞれの直下要素( > * ) に対してスタイルをセットした方がネスト時の影響をなくせるが、wrapper のネストが多様されることは少ないので親側の変数管理のみで実装。
.-contentSize\:s {
--contentSize: var(--sz--s);
}
.-contentSize\:l {
--contentSize: var(--sz--l);
} Direct children receive inline-size: 100%, so even elements whose natural width is below --contentSize (short paragraphs, <table>, etc.) always stretch to the parent width. This keeps widths consistent under l--stack and other vertical layouts and prevents jagged edges.
A <table> that is a direct child of is--wrapper loses its content-driven natural width — it always stretches to fill the wrapper. To preserve the table’s intrinsic width, wrap it in another element so it is no longer a direct child of is--wrapper.
Using with Lism Components
It can be applied via the isWrapper property on any component.
| Property | Output |
|---|---|
isWrapper | is--wrapper |
isWrapper='s' | is--wrapper, -contentSize:s |
isWrapper='l' | is--wrapper, -contentSize:l |
isWrapper={value} | is--wrapper, --contentSize:{value} |
A dedicated <Wrapper> component is also available as an alias for <Lism isWrapper>.
Import
import { Wrapper } from 'lism-css/react'; Props
| Property | Description |
|---|---|
contentSize | Specifies the content size. |
layout | Specifies the Layout Primitive to expand into. |
isContainer | Sets the container type. |
// ①<Flow isWrapper="s" isContainer>...</Flow>
// ②<Wrapper contentSize="s" layout="flow" isContainer>...</Wrapper>Usage
Example
Content
Content
…
<Wrapper layout="flow" p="20"> <p>Content</p> <p>Content</p> <p>...</p></Wrapper>contentSize='s'Content
Content
…
<Wrapper contentSize="s" layout="flow" p="20"> <p>Content</p> <p>Content</p> <p>...</p></Wrapper>Setting a custom container size
To use a value other than s or l, pass any value to isWrapper and it will be output as the --contentSize CSS variable.
<Lism isWrapper="20rem" p="20"> <div>Contents...</div> <div>Contents...</div></Lism>Demo Page
A demo page is available where you can explore the behavior of is--wrapper.
We recommend viewing it on a wide screen.