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%);
> * {
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);
} 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. |
↓
The examples ① and ② below produce the same result.
// ①<Flow isWrapper="s" isContainer>...</Flow>
// ②<Wrapper contentSize="s" layout="flow" isContainer>...</Wrapper>Usage
Example
↓
Example
Content
Content
…
リサイズ可能
<Wrapper layout="flow" p="20"> <p>Content</p> <p>Content</p> <p>...</p></Wrapper> ↓
With
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.
↓
Setting a custom value on is—wrapper
Contents…
Contents…
リサイズ可能
<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.
大きい画面で見る