Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-slot

Package Overview
Dependencies
Maintainers
8
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-slot

  • 0.1.1-rc.13
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10M
decreased by-3.49%
Maintainers
8
Weekly downloads
 
Created

What is @radix-ui/react-slot?

The @radix-ui/react-slot package is a utility for React that allows you to distribute elements as 'slots'. It is useful for component libraries and design systems where you want to provide a flexible API for component composition. It allows users to replace elements within a component while still maintaining the component's logic and styling.

What are @radix-ui/react-slot's main functionalities?

Slotting elements

This code demonstrates how to use the @radix-ui/react-slot package to create a flexible Button component that can render as a 'button' or as any other element passed to it, while preserving the button's behavior and styles.

{"import * as React from 'react';\nimport { Slot } from '@radix-ui/react-slot';\n\nfunction Button({ children, asChild }) {\n  const Component = asChild ? Slot : 'button';\n  return <Component>{children}</Component>;\n}\n\nexport default function App() {\n  return (\n    <div>\n      <Button>Default button</Button>\n      <Button asChild>\n        <a href=\"#\">Link with button styling</a>\n      </Button>\n    </div>\n  );\n}"}

Other packages similar to @radix-ui/react-slot

FAQs

Package last updated on 13 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc