导航栏是屏幕顶部的一个固定区域,包含页面标题和导航元素。
以下组件已包含
导航栏
NavbarBackLink
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
bgClass | 字符串 | 要添加到导航栏的“背景”元素上的额外类 | |
centerTitle | 布尔值 | 未定义 | 使导航栏标题居中。如果未指定,则将其设置为在 iOS 主题中居中 |
colors | 对象 | 包含 Tailwind CSS 颜色类别的对象 | |
colors.bgIos | 字符串 | 'bg-ios-light-surface-2 dark:bg-ios-dark-surface-2' | |
colors.bgMaterial | 字符串 | 'bg-md-light-surface-2 dark:bg-md-dark-surface-2' | |
colors.textIos | 字符串 | 'text-black dark:text-white' | |
colors.textMaterial | 字符串 | 'text-md-light-on-surface dark:text-md-dark-on-surface' | |
fontSizeIos | 字符串 | 'text-[17px]' | iOS 主题中字体大小的 Tailwind CSS 类 |
fontSizeMaterial | 字符串 | 'text-[16px]' | Material 主题中字体大小的 Tailwind CSS 类 |
innerClass | 字符串 | 要添加到导航栏的“内部”元素上的额外类 | |
large | 布尔值 | false | 呈现具有额外行的大尺寸导航栏,用于大尺寸标题,在大尺寸标题滚动时会变为通常的大小 |
left | 字符串 | 导航栏“左侧”区域的内容 | |
leftClass | 字符串 | 要添加到导航栏的“左侧”元素上的额外类 | |
medium | 布尔值 | false | 呈现具有额外行的中等尺寸导航栏,用于中等尺寸标题,在中等尺寸标题滚动时会变为通常的大小 |
outline | 布尔值 | 未定义 | 呈现外部细线(边框)。如果未指定,则将为 iOS 主题启用 |
right | 字符串 | 导航栏“右侧”区域的内容 | |
rightClass | 字符串 | 要添加到导航栏的“右侧”元素上的额外类 | |
scrollEl | 任何 | 未定义 | 中等/大/透明导航栏的正确“折叠”功能所需的元素。如果未指定,它将使用导航栏的父元素 |
subnavbar | 字符串 | 导航栏“子导航栏”区域的内容 | |
subnavbarClass | 字符串 | 要添加到导航栏的“子导航栏”元素上的额外类 | |
subtitle | 字符串 | 导航栏“副标题”区域的内容 | |
subtitleClass | 字符串 | 要添加到导航栏的“副标题”元素上的额外类 | |
title | 字符串 | 导航栏“标题”区域的内容 | |
titleClass | 字符串 | 要添加到导航栏的“标题”元素上的额外类 | |
titleFontSizeIos | 字符串 | 'text-[17px]' | iOS 主题中导航栏标题字体大小的 Tailwind CSS 类 |
titleFontSizeMaterial | 字符串 | 'text-[22px]' | Material 主题中导航栏标题字体大小的 Tailwind CSS 类 |
titleLargeFontSizeIos | 字符串 | 'text-[34px]' | iOS 主题中大尺寸导航栏标题字体大小的 Tailwind CSS 类 |
titleLargeFontSizeMaterial | 字符串 | 'text-[28px]' | Material 主题中大尺寸导航栏标题字体大小的 Tailwind CSS 类 |
titleMediumFontSizeIos | 字符串 | 'text-[24px]' | iOS 主题中中等尺寸导航栏标题字体大小的 Tailwind CSS 类 |
titleMediumFontSizeMaterial | 字符串 | 'text-[24px]' | Material 主题中中等尺寸导航栏标题字体大小的 Tailwind CSS 类 |
translucent | 布尔值 | true | 在 iOS 主题中使导航栏背景半透明(使用 |
transparent | 布尔值 | false | 呈现透明导航栏,滚动时会变为不透明 |
名称 | 描述 |
---|---|
left | 导航栏“左侧”区域的内容 |
right | 导航栏“右侧”区域的内容 |
subnavbar | 导航栏“子导航栏”区域的内容 |
subtitle | 导航栏“副标题”区域的内容 |
title | 导航栏“标题”区域的内容 |
NavbarBackLink
应放置在导航栏的“左侧”区域
<Navbar title="My App">
<NavbarBackLink slot="left" text="Back" onClick={() => history.back()} />
</Navbar>
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
component | 字符串 | 'a' | 组件的 HTML 元素 |
showText | 布尔值 | 'auto' | 'auto' | 定义是否显示链接文本。当为 'auto' 时,它会为 Material 主题隐藏链接文本 |
text | 字符串 | 'Back' | 返回链接的文本内容 |
onClick | function(e) | 链接点击处理程序 | |
onClick | function(e) |
|
名称 | 描述 |
---|---|
text | 返回链接的文本内容 |
<script>import {Page,Navbar,NavbarBackLink,Link,Block,BlockHeader,BlockTitle,Radio,Toggle,List,ListItem,} from 'konsta/svelte';let size = 'Default';let isTransparent = false;</script><Page><Navbartitle="Navbar"subtitle="Subtitle"class="top-0 sticky"medium={size === 'Medium'}large={size === 'Large'}transparent={isTransparent}><Link slot="right" navbar>Right</Link></Navbar><div class="relative"><Block strong inset><p>Navbar is a fixed area at the top of a screen that contains Page titleand navigation elements.</p></Block><BlockTitle>Size</BlockTitle><BlockHeader>Medium and Large will collapse to usual size on page scroll</BlockHeader><List strong inset>{#each ['Default', 'Medium', 'Large'] as v}<ListItem key={v} label title={v}><Radioslot="after"component="div"value={v}checked={size === v}onChange={() => (size = v)}/></ListItem>{/each}</List><BlockTitle>Transparent</BlockTitle><BlockHeader>When navbar is transparent, its title and background will become visibleon page scroll</BlockHeader><List strong inset><ListItem label title="Transparent"><Toggleslot="after"component="div"checked={isTransparent === true}onChange={() => (isTransparent = !isTransparent)}/></ListItem></List><Block strong inset className="space-y-4"><p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Iusto temporeratione unde accusantium distinctio nulla quia numquam earum odio,optio, nisi rem deserunt. Molestiae delectus, ut assumenda numquam magnienim.</p><p>Architecto molestias cum dolor dolorem provident consequuntur inciduntsunt fugiat tenetur odio, recusandae placeat rem veniam. Voluptates,repellendus odit, magni nesciunt, optio laborum asperiores repudiandaeconsectetur suscipit ab cupiditate eum.</p><p>Aliquam, iste accusamus deleniti temporibus exercitationem nequeperferendis optio, blanditiis quisquam molestias perspiciatis cumqueharum tenetur veniam. Dolorum fugit doloribus est, deserunt, eligendi,quaerat quidem itaque tempore laborum non illum?</p><p>Rerum magni sunt quis veniam, dolor ratione saepe ducimus temporevoluptatum porro quod commodi? Aperiam laudantium deleniti totam dolorumqui accusantium iste saepe facere optio, soluta maxime mollitia deseruntcumque.</p><p>Iusto tempore quis provident, saepe illum ex ipsum cupiditate explicaboratione unde facere nemo delectus harum, blanditiis eius sit asperioresnam. Aut cupiditate est tempore officia, perspiciatis esse asperioresrepudiandae?</p><p>Consequuntur itaque harum eos vero, reiciendis dolorum iure non earummolestias tenetur sint enim, maxime recusandae ad perferendisrepudiandae! Sit, quos exercitationem beatae numquam laborum nobisnatus. Obcaecati, ea inventore.</p><p>Fugit culpa labore sapiente excepturi reiciendis, nulla, nihil neque utveritatis quis quibusdam dolorum? Voluptatibus animi officiaperspiciatis doloremque cum voluptatem, quia ratione modi vero,consequatur ipsum, praesentium quibusdam amet?</p><p>Laudantium nihil sint nam placeat, nemo rerum ipsam explicabo iustodolores molestiae expedita eos consequuntur ut architecto consequatursoluta ad maiores voluptatem tenetur in velit. Minima quia molestiaenobis voluptatibus.</p><p>Expedita soluta quia inventore et placeat id exercitationem quisquameligendi est eius sapiente quo, cum nesciunt mollitia, sit veniamducimus tempora culpa adipisci commodi in autem nihil voluptatemcorporis? Perspiciatis.</p><p>Molestias, est? Eligendi vero distinctio voluptatem cumque idvoluptatibus, officia minima repellendus sit illo tempora laboreprovident? Eum tenetur consectetur quae, in facilis autem ipsamdoloribus voluptate vitae suscipit nobis.</p><p>Obcaecati optio iste hic, soluta minus ullam, perferendis pariatur nonpossimus autem nostrum libero sapiente. Corporis quo cum iustoexercitationem velit. Non beatae eveniet asperiores ipsa consequunturtemporibus sapiente earum!</p><p>Temporibus, omnis. Excepturi dolorum expedita laudantium quasi quod idadipisci, esse, nam atque in, incidunt ex ab distinctio repellendusbeatae voluptatem alias odit illum quis. Illo numquam voluptatibus errorvoluptatum!</p></Block></div></Page>
<script>import {Page,Navbar,NavbarBackLink,Block,Segmented,SegmentedButton,} from 'konsta/svelte';</script><Page><Navbar title="Subnavbar"><Segmentedslot="subnavbar"strongactiveButtonIndex={0}childButtonsLength={3}><SegmentedButton small strong active>Button</SegmentedButton><SegmentedButton small strong>Button</SegmentedButton><SegmentedButton small strong>Button</SegmentedButton></Segmented></Navbar><div class="relative"><Block strongIos outlineIos><p>Subnavbar is useful when you need to put any additional elements intoNavbar, like Tab Links or Search Bar. It also remains visible whenNavbar hidden.</p></Block></div></Page>