@flourish/ui-styles

中文文档
7.0.2发布于 2026/10/28LicenseRef-LICENSEESM + CJS近 30 天下载 5754

Flourish module for styling UI elements

原始使用文档
文档目录4 节
  1. How to install
  2. Basics
  3. Styling searchboxes
  4. Using defaults from @flourish/layout

Flourish UI Styles

Style UI elements (like @flourish/controls) in Flourish templates.

How to install

npm install -s @flourish/ui-styles

Add one or more control style objects to your template state:

export var state = {
    controls_style: {},
    button_style: {},
    dropdown_style: {},
    slider_style: {},
    searchbox_style: {},
}

Import settings for controls styling in your template.yml settings.

- property: controls_style
  import: "@flourish/ui-styles/controls-style"
- property: dropdown_style
  import: "@flourish/ui-styles/dropdown-style"
- property: button_style
  import: "@flourish/ui-styles/button-style"
- property: slider_style
  import: "@flourish/ui-styles/slider-style"
- property: searchbox_style
  import: "@flourish/ui-styles/searchbox-style"

Basics

Initialise the styling outside any function or in a special init function:

import { createGeneralControlsStyle, createButtonStyle, createDropdownStyle, createSliderStyle, createSearchboxStyle } from "@flourish/ui-styles";
var controlsStyle = createGeneralControlsStyle(state.controls_style, ".fl-control"),
    buttonStyle = createButtonStyle(state.button_style, ".fl-control-buttons"),
    dropdownStyle = createDropdownStyle(state.dropdown_style, ".fl-control-dropdown"),
    sliderStyle = createSliderStyle(state.slider_style, ".fl-control-slider"),
    searchboxStyle = createSearchboxStyle(state.searchbox_style, ".fl-control-searchbox");

The init function takes the state object as a first argument. The second argument is the target container for styling. If you are using @flourish/controls you can just use the selectors in the code above.

If you're using this on custom HTML, make sure to target the direct parent container of your controls, and make sure to give your controls a classname of fl-control. If you're using specifically the button styles with custom HTML make sure your buttons also have a button class and your selected elements a selected class.

Then in the update function, make sure to update the styles with update(). To ensure right-to-left read direction support works correctly call the style update functions after the read direction of the template has been updated (i.e. layout.update() has been called).

controlsStyle.update();
buttonStyle.update();
dropdownStyle.update();
sliderStyle.update();
searchboxStyle.update();

Styling searchboxes

Use createSearchboxStyle with the searchbox control from @flourish/controls to style the search input, icon and suggestion dropdown. The imported settings let you keep the input expanded and customize its size, background color and opacity, text/icon color, stroke opacity and border radius.

Search behaviour, such as placeholder text and suggestions, is configured separately in the searchbox control settings.

Using defaults from @flourish/layout

There is an optional feature that allows you to inherit text and background color from the layout module. Just pass in the layout state object as a third argument when initializing the styles.

import { createButtonStyle } from "@flourish/ui-styles";
var buttonStyle = createButtonStyle(state.button_style, ".fl-control-buttons", state.layout);

Searchbox styles also support this argument. When no searchbox text or background color is set, they use the corresponding layout color:

var searchboxStyle = createSearchboxStyle(state.searchbox_style, ".fl-control-searchbox", state.layout);

版本与发布记录

@flourish/ui-styles 共发布 22 个版本,首次发布于 2019/11/30;过去 12 个月发布了 4 个版本。

版本发布日期距今
7.0.2latest2026/10/2818 天前
7.0.12026/09/012 个月前
7.0.02026/06/115 个月前
6.0.22026/05/225 个月前
6.0.12025/01/101.8 年前
6.0.02024/07/312 年前

关于 @flourish/ui-styles 的常见问题

@flourish/ui-styles 是什么?

Flourish module for styling UI elements

如何安装 @flourish/ui-styles?

在项目目录运行 npm install @flourish/ui-styles,或使用 pnpm add / yarn add / bun add。

@flourish/ui-styles 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/flourish__ui-styles 是否存在。

@flourish/ui-styles 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@flourish/ui-styles 可以商用吗?

@flourish/ui-styles 使用 LicenseRef-LICENSE 许可。声明的许可为 LicenseRef-LICENSE,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@flourish/ui-styles 的下载量有多少?

根据 npm 官方下载统计,@flourish/ui-styles 在 2026/10/15 – 2026/11/13 这 30 天内被下载 5,754 次,日均约 192 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@flourish/ui-styles 还在维护吗?

最新版本 7.0.2 发布于 2026/10/28(18 天前);至今共发布 22 个版本,其中过去 12 个月发布了 4 个;首次发布于 2019/11/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。