Component Usage
Fluent UI Team edited this page Apr 9, 2022
·
4 revisions
Some components like the <Link />
component allow you to override the rendered DOM node. This can be useful in cases where you want to control the rendered output.
The Link component has the following default behavior
// This will render as an anchor as there is an href.
<Link href="https://www.github.com" />
// Because there is no href this will render a button.
<Link onClick={() => alert('Hello')} />
If for some reason the above does not fit your usecase you can chose to override by proving a HTML tag name or a React Component.
Lets say your application would require Links to be rendered as <Route />
elements.
import { Route } from './router';
// Specify what to render by providing a Component
<Link as={Route} onClick={() => alert('Hello')} />;
If your link has complex children that also require onClick you might run into trouble when Fluent UI React renders a button as a child of a button. In that case you could override the HTML component of the parent by providing the as
prop.
// Specify what to render by providing an HTML tag name
<Link as="div" onClick={() => alert('Hello')}>
<Link onClick={() => alert('World')}>World</Link>
</Link>
- FAQ - Fabric and Stardust to Fluent UI
-
@fluentui/react
Version 9 -
@fluentui/react
Version 8 - Contributing to the
7.0
branch - How to apply themes (version 7/8)
- Planning and development process (for work by the core team)
- Conducting meetings Style guide
- Keeping up with review requests
- RFC review process
- Setup (configuring your environment)
- Fluent UI React version 7/8
- CLA
- Overview
- Repo structure
- Development process
- Contributing to previous versions
- API Extractor
- Build command changes made in early 2020
- Component implementation guide
- Creating a component
- Implementation Best Practices
- Theming
- Documenting
- Styling (old approach)
- Overview
- Testing with Jest
- E2E testing (Cypress)
- Visual testing (Screener)
- Accessibility review checklist