🔥 遇见我们的新项目 t0ggles - 您终极的项目管理工具! 🔥

导航栏 Svelte 组件

导航栏是屏幕顶部的一个固定区域,包含页面标题和导航元素。

以下组件已包含

  • 导航栏
  • 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 主题中使导航栏背景半透明(使用 backdrop-filter: blur

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'

返回链接的文本内容

onClickfunction(e)

链接点击处理程序

onClickfunction(e)

click 事件处理程序

名称描述
text

返回链接的文本内容

示例

Navbar.svelte
<script>
import {
Page,
Navbar,
NavbarBackLink,
Link,
Block,
BlockHeader,
BlockTitle,
Radio,
Toggle,
List,
ListItem,
} from 'konsta/svelte';
let size = 'Default';
let isTransparent = false;
</script>
<Page>
<Navbar
title="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 title
and 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}>
<Radio
slot="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 visible
on page scroll
</BlockHeader>
<List strong inset>
<ListItem label title="Transparent"
><Toggle
slot="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 tempore
ratione unde accusantium distinctio nulla quia numquam earum odio,
optio, nisi rem deserunt. Molestiae delectus, ut assumenda numquam magni
enim.
</p>
<p>
Architecto molestias cum dolor dolorem provident consequuntur incidunt
sunt fugiat tenetur odio, recusandae placeat rem veniam. Voluptates,
repellendus odit, magni nesciunt, optio laborum asperiores repudiandae
consectetur suscipit ab cupiditate eum.
</p>
<p>
Aliquam, iste accusamus deleniti temporibus exercitationem neque
perferendis optio, blanditiis quisquam molestias perspiciatis cumque
harum 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 tempore
voluptatum porro quod commodi? Aperiam laudantium deleniti totam dolorum
qui accusantium iste saepe facere optio, soluta maxime mollitia deserunt
cumque.
</p>
<p>
Iusto tempore quis provident, saepe illum ex ipsum cupiditate explicabo
ratione unde facere nemo delectus harum, blanditiis eius sit asperiores
nam. Aut cupiditate est tempore officia, perspiciatis esse asperiores
repudiandae?
</p>
<p>
Consequuntur itaque harum eos vero, reiciendis dolorum iure non earum
molestias tenetur sint enim, maxime recusandae ad perferendis
repudiandae! Sit, quos exercitationem beatae numquam laborum nobis
natus. Obcaecati, ea inventore.
</p>
<p>
Fugit culpa labore sapiente excepturi reiciendis, nulla, nihil neque ut
veritatis quis quibusdam dolorum? Voluptatibus animi officia
perspiciatis doloremque cum voluptatem, quia ratione modi vero,
consequatur ipsum, praesentium quibusdam amet?
</p>
<p>
Laudantium nihil sint nam placeat, nemo rerum ipsam explicabo iusto
dolores molestiae expedita eos consequuntur ut architecto consequatur
soluta ad maiores voluptatem tenetur in velit. Minima quia molestiae
nobis voluptatibus.
</p>
<p>
Expedita soluta quia inventore et placeat id exercitationem quisquam
eligendi est eius sapiente quo, cum nesciunt mollitia, sit veniam
ducimus tempora culpa adipisci commodi in autem nihil voluptatem
corporis? Perspiciatis.
</p>
<p>
Molestias, est? Eligendi vero distinctio voluptatem cumque id
voluptatibus, officia minima repellendus sit illo tempora labore
provident? Eum tenetur consectetur quae, in facilis autem ipsam
doloribus voluptate vitae suscipit nobis.
</p>
<p>
Obcaecati optio iste hic, soluta minus ullam, perferendis pariatur non
possimus autem nostrum libero sapiente. Corporis quo cum iusto
exercitationem velit. Non beatae eveniet asperiores ipsa consequuntur
temporibus sapiente earum!
</p>
<p>
Temporibus, omnis. Excepturi dolorum expedita laudantium quasi quod id
adipisci, esse, nam atque in, incidunt ex ab distinctio repellendus
beatae voluptatem alias odit illum quis. Illo numquam voluptatibus error
voluptatum!
</p>
</Block>
</div>
</Page>
Subnavbar.svelte
<script>
import {
Page,
Navbar,
NavbarBackLink,
Block,
Segmented,
SegmentedButton,
} from 'konsta/svelte';
</script>
<Page>
<Navbar title="Subnavbar">
<Segmented
slot="subnavbar"
strong
activeButtonIndex={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 into
Navbar, like Tab Links or Search Bar. It also remains visible when
Navbar hidden.
</p>
</Block>
</div>
</Page>
代码许可证为 MIT.
2022 © Konsta UI by nolimits4web.