@doabit/semantic-ui-sass

中文文档
2.4.5发布于 2021/06/21MITCommonJS零依赖近 30 天下载 3786

semantic-ui-sass npm package

原始使用文档
文档目录19 节
  1. NOTE
  2. Installation and Usage
  3. CSS
  4. Custom font
  5. Skip font loading
  6. Custom font family
  7. Skip use of custom scrollbars
  8. All variables, you can custom any of that
  9. Javascripts
  10. Ruby on Rails Version 5
  11. Ruby on Rails Version 6+ with webpacker
  12. New project
  13. Existing project
  14. NOTE
  15. Breadcrumbs helper
  16. Flash helper
  17. Icon helper
  18. TODO
  19. Contributing

Semantic UI for Sass

semantic-ui-sass is an Sass-powered version of Semantic UI and ready to drop into Rails, Compass, or Sprockets.

Build Status

NOTE

The gem only has default theme.

Installation and Usage

gem 'semantic-ui-sass'

bundle install and restart your server to make the files available through the pipeline.

semantic-ui-sass with Rails or Sprockets

CSS

Import Semantic in an SCSS file (for example, application.css.scss) to get all of Semantic's styles

@import 'semantic-ui';

You can also include modules

@import 'semantic-ui/collections/menu';

Custom font

$font-url: 'http://fonts.useso.com/css?family=Lato:400,700,400italic,700italic&subset=latin';
@import 'semantic-ui';

Skip font loading

$import-google-fonts: false;
@import 'semantic-ui';

Custom font family

$font-family: 'custom-font-family';
@import 'semantic-ui';

Skip use of custom scrollbars

$use-custom-scrollbars: false;
@import 'semantic-ui';

All variables, you can custom any of that

Fonts:

$font-name: 'Lato' !default;
$font-family: $font-name, 'Helvetica Neue', Arial, Helvetica, sans-serif !default;
$font-url: 'https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic&subset=latin,latin-ext' !default;
$import-google-fonts: true !default;

Scrollbars:

$use-custom-scrollbars: true !default;

Breakpoints:

$mobile-breakpoint: 320px !default;
$tablet-breakpoint: 768px !default;
$computer-breakpoint: 992px !default;
$large-monitor-breakpoint: 1200px !default;
$widescreen-monitor-breakpoint: 1920px !default;

Javascripts

Ruby on Rails Version 5

We have a helper that includes all Semantic javascripts. Put this in your Javascript manifest (usually in application.js) to

// Loads all Semantic javascripts
//= require semantic-ui

You can also load individual modules, provided you also require any dependencies.

//= require semantic-ui/modal
//= require semantic-ui/dropdown

Ruby on Rails Version 6+ with webpacker

Add packages with yarn:

yarn add jquery popper.js @doabit/semantic-ui-sass

In config/webpack/environment.js add the following:

const webpack = require('webpack')

environment.plugins.append(
  'Provide',
  new webpack.ProvidePlugin({
    $: 'jquery',
    jQuery: 'jquery',
    Popper: ['popper.js', 'default']
  })
)

In app/javascript/packs/application.js add the following:

import '@doabit/semantic-ui-sass'

If you use webpakcer to import stylesheet, you should add

import '@doabit/semantic-ui-sass/src/scss/semantic-ui.scss'

semantic-ui-sass with Compass

New project

Install the gem and create a new project using the gem.

gem install semantic-ui-sass
compass create compass-project -r semantic-ui-sass --using semantic-ui

This will sort a few things out:

  • You'll get a starting styles.scss
  • You'll get a compiled stylesheet compiled & ready to drop into your application
  • We'll also copy the Semantic javascripts & images & fonts into their respective folders for you

Existing project

Install the gem, add the require statement to the top of your configuration file, and install the extension.

gem install semantic-ui-sass
# In config.rb
require 'semantic-ui-sass'
compass install semantic-ui

NOTE

When using compass, you should visit file in local server, eg http://localhost:3000/index.html, rather than file:///Users/doabit/demo/index.html

Rails Helpers

Breadcrumbs helper

Add breadcrumbs helper <%= semantic_breadcrumbs %> to your layout.

class ApplicationController
  semantic_breadcrumb :index, :root_path
end
class ExamplesController < ApplicationController
  semantic_breadcrumb :index, :examples_path

  def index
  end

  def show
    @example = Example.find params[:id]
    semantic_breadcrumb @example.name, example_path(@example)
    # semantic_breadcrumb :show, example_path(@example)
  end
end

Flash helper

Add flash helper <%= semantic_flash %> to your layout

Icon helper

semantic_icon('add')
# => <i class="add icon"></i>
semantic_icon(:add)
# => <i class="add icon"></i>
semantic_icon('add sign')
# => <i class="add sign icon"></i>
semantic_icon('add', 'sign')
# => <i class="add sign icon"></i>
semantic_icon(:add, :sign)
# => <i class="add sign icon"></i>
semantic_icon('add', id: 'id')
# => <i class="add icon" id="id"></i>

TODO

  • Add global variables
  • Add rails helpers like render_flash?

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

版本与发布记录

@doabit/semantic-ui-sass 共发布 2 个版本,首次发布于 2021/06/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.4.5latest2021/06/215 年前
2.4.42021/06/195 年前

关于 @doabit/semantic-ui-sass 的常见问题

@doabit/semantic-ui-sass 是什么?

semantic-ui-sass npm package

如何安装 @doabit/semantic-ui-sass?

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

@doabit/semantic-ui-sass 支持 TypeScript 吗?

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

@doabit/semantic-ui-sass 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@doabit/semantic-ui-sass 可以商用吗?

@doabit/semantic-ui-sass 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@doabit/semantic-ui-sass 的下载量有多少?

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

@doabit/semantic-ui-sass 还在维护吗?

最新版本 2.4.5 发布于 2021/06/21(5 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/06/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。