npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@libs-ui/components-switch

v0.2.356-1

Published

> Component chuyển đổi trạng thái (On/Off) dạng Switch (Toggle).

Readme

@libs-ui/components-switch

Component chuyển đổi trạng thái (On/Off) dạng Switch (Toggle).

Giới thiệu

LibsUiComponentsSwitchComponent là một standalone Angular component cung cấp giao diện Switch Button. Component hỗ trợ 2 kích thước, trạng thái disable và hỗ trợ binding hai chiều (model) cho trạng thái active.

Tính năng

  • ✅ 2 kích thước: Default và Large
  • ✅ Hỗ trợ trạng thái Disabled
  • ✅ Two-way binding với Signals (active)
  • ✅ Event output chi tiết (kèm hàm revert để hoàn tác)
  • ✅ Custom Styling với CSS Variable

Khi nào sử dụng

  • Khi người dùng cần chuyển đổi nhanh giữa hai trạng thái (Bật/Tắt).
  • Thay thế cho Checkbox khi muốn thể hiện hành động có hiệu lực tức thì.
  • Trong các trang cài đặt hệ thống, kích hoạt tính năng.

Cài đặt

# npm
npm install @libs-ui/components-switch

# yarn
yarn add @libs-ui/components-switch

Import

import { LibsUiComponentsSwitchComponent } from '@libs-ui/components-switch';

@Component({
  standalone: true,
  imports: [LibsUiComponentsSwitchComponent],
  // ...
})
export class YourComponent {}

Ví dụ

Basic (Default Size)

<libs_ui-components-switch [(active)]="isActive" />

Large Size

<libs_ui-components-switch
  size="large"
  [(active)]="isActive" />

Disabled State

<libs_ui-components-switch
  [disable]="true"
  [active]="true" />

Handling Change Event

Sử dụng (outSwitch) để xử lý sự kiện active thay đổi. Event cung cấp hàm revert() để quay lại trạng thái cũ nếu cần (ví dụ: API call thất bại).

<libs_ui-components-switch (outSwitch)="onSwitchChange($event)" />
onSwitchChange(event: ISwitchEvent) {
  console.log('New state:', event.active);
  // Nếu muốn hoàn tác:
  // event.revert();
}

API

LibsUiComponentsSwitchComponent

Selector: libs_ui-components-switch

Inputs

| Property | Type | Default | Description | | ------------ | ---------------------- | ----------- | --------------------------------------------- | | [size] | 'default' \| 'large' | 'default' | Kích thước của switch. | | [disable] | boolean | false | Vô hiệu hóa switch (không thể click). | | [(active)] | boolean | false | Trạng thái bật/tắt của switch (Model Signal). |

Outputs

| Property | Type | Description | | ------------- | -------------- | ------------------------------------------------- | | (outSwitch) | ISwitchEvent | Emit khi người dùng click để thay đổi trạng thái. |

Interfaces

ISwitchEvent

export interface ISwitchEvent {
  active: boolean; // Trạng thái mới sau khi click
  revert: () => Promise<void>; // Hàm utility để quay về trạng thái cũ
}

Styling

Component sử dụng CSS Variables để tùy biến màu sắc:

| Variable | Default | Description | | ------------------------- | ---------------- | ------------------- | | --libs-ui-color-default | #226ff5 (Blue) | Màu nền khi active. |

Demo

npx nx serve core-ui

Truy cập: http://localhost:4500/switch