ReactJS Semantic UI TransitionablePortal Addons
Last Updated :
06 Aug, 2024
Semantic UI is a modern framework used in developing seamless designs for the website. It gives the user a lightweight experience with its components. It uses the predefined CSS and JQuery languages to incorporate into different frameworks.
In this article, we will find out how to use TransitionablePortal Addons in ReactJS Semantic UI. TransitionablePortal add-ons are used to render it anywhere on the page.
Property:
- Controlled: The controlled property is used to make the controlled TransitionablePortal. For the control, it is used to define the transition.
- bsPrefix: This prop is used to denote the change in a component in CSS. It is used to customize the bootstrap CSS. The default value is the spinner and the type is a string.
- size: The size of props is used to demonstrate the size of the spinner. The size of props is used in component size variations. The type of size is sm.
- color: The color props are used to denote the color of the spinner.
- className: The className props are used to denote the class name for styling the component in CSS.
- children: It is used to pass the children element to this component in React JS. The type of children is an element.
Syntax:
<TransitionablePortal>Children content</TransitionablePortal>
Creating React Application And Installing Module:
Step 1: Create a React application using the following command.
npx create-react-app foldername
Step 2: After creating your project folder i.e. folder name, move to it using the following command.
cd foldername
Step 3: Install semantic UI in your given directory.
npm install semantic-ui-react semantic-ui-css
Project Structure: It will look like the following.

Step to Run Application: Run the application from the root directory of the project, using the following command.
npm start
Example 1: This is the basic example that shows how to use TransitionablePortal addons.
App.js
import React, { Component } from 'react'
import { Button, Grid, Header, Segment,
TransitionablePortal } from 'semantic-ui-react'
const styleLink = document.createElement("link");
styleLink.rel = "stylesheet";
styleLink.href =
"https://cdn.jsdelivr.net/npm/semantic-ui/dist/semantic.min.css";
document.head.appendChild(styleLink);
export default class
TransitionablePortalExampleTransitionablePortal
extends Component {
state = {
open: false,
}
Open = () => {
this.setState({ open: true })
}
Close = () => {
this.setState({ open: false })
}
render() {
const { open } = this.state
return (
<div id='gfg'>
<Grid columns={2}>
<Grid.Column>
<TransitionablePortal
closeOnTriggerClick
openOnTriggerClick
trigger={
<Button
content={open ? 'Close TransitionablePortal'
: 'Open TransitionablePortal'}
negative={open}
positive={!open}
/>
}
onOpen={this.Open}
onClose={this.Close}
>
<Segment
style={{
left: '32%',
position: 'fixed',
top: '2%',
zIndex: 1000,
}}
>
<Header><h1>GeeksforGeeks</h1></Header>
<p>Computer Science Portal</p>
</Segment>
</TransitionablePortal>
</Grid.Column>
</Grid>
</div>
)
}
}
index.css
Output:
Example 2: In this example, we have set the transition to 1000 in TransitionablePortal addons.
App.js
import React, { Component } from 'react'
import { Button, Grid, Header, Segment,
TransitionablePortal } from 'semantic-ui-react'
const styleLink = document.createElement("link");
styleLink.rel = "stylesheet";
styleLink.href =
"https://cdn.jsdelivr.net/npm/semantic-ui/dist/semantic.min.css";
document.head.appendChild(styleLink);
export default class
TransitionablePortalExampleTransitionablePortal
extends Component {
state = {
open: false,
}
Open = () => {
this.setState({ open: true })
}
Close = () => {
this.setState({ open: false })
}
render() {
const { open } = this.state
return (
<div id='gfg'>
<Grid columns={2}>
<Grid.Column>
<TransitionablePortal
transition = {{
animation: 'scale',
duration: 1000,}}
closeOnTriggerClick
openOnTriggerClick
trigger={
<Button
content={open ?
'Close TransitionablePortal' :
'Open TransitionablePortal'}
negative={open}
positive={!open}
/>
}
onOpen={this.Open}
onClose={this.Close}
>
<Segment
style={{
left: '32%',
position: 'fixed',
top: '2%',
zIndex: 1000,
}}
>
<Header><h1>GeeksforGeeks</h1></Header>
<p>Computer Science Portal</p>
</Segment>
</TransitionablePortal>
</Grid.Column>
</Grid>
</div>
)
}
}
index.css
Output:
Reference: https://react.semantic-ui.com/addons/transitionable-portal
Similar Reads
ReactJS Semantic UI Textarea Addons
Semantic UI is a modern framework used in developing seamless designs for the website, It gives the user a lightweight experience with its components. It uses the predefined CSS, JQuery language to incorporate in different frameworks. In this article we will know how to use Textarea Addons in ReactJ
2 min read
ReactJS Semantic UI Transition Module
Semantic UI is a modern framework used in developing seamless designs for the website, It gives the user a lightweight experience with its components. It uses the predefined CSS, JQuery language to incorporate in different frameworks. In this article, we will know how to use the Transition Module in
3 min read
ReactJS Semantic UI Table Collections
Semantic UI is a modern framework used in developing seamless designs for the website, It gives the user a lightweight experience with its components. It uses the predefined CSS, JQuery language to incorporate in different frameworks. In this article we will know how to use table collections in Reac
3 min read
ReactJS Semantic UI Ref Addons
Semantic UI is a modern framework used in developing seamless designs for the website. It gives the user a lightweight experience with its components. It uses predefined CSS and JQuery to incorporate different frameworks. In this article, we will learn how to use Ref Addons in ReactJS Semantic UI. R
2 min read
Semantic-UI Browse Transition
Semantic UI is an open-source framework that uses CSS and jQuery to build great user interfaces. It is the same as a bootstrap for use and has great different elements to use to make your website look more amazing. In this article, we are going to learn about browse transition. Semantic UI has a bun
2 min read
Semantic-UI Drop Transition
Semantic UI is an open-source framework that uses CSS and jQuery to build great user interfaces. It is the same as a bootstrap for use and has great different elements to use to make your website look more amazing. Semantic UI Transition is an animation that is used to move the webpage content in or
2 min read
Semantic-UI Scale Transition
Semantic UI is an open-source framework that uses CSS and jQuery to build great user interfaces. It is the same as a bootstrap for use and has great different elements to use to make your website look more amazing. In this article, we are going to learn about scale transition. It is equipped with pr
2 min read
ReactJS Semantic UI Step Element
Semantic UI is a modern framework used in developing seamless designs for the website, It gives the user a lightweight experience with its components. It uses the predefined CSS, JQuery language to incorporate in different frameworks. In this article we will know how to use the step element in React
2 min read
ReactJS Semantic UI Radio Addons
Semantic UI is a modern framework used in developing seamless designs for the website, It gives the user a lightweight experience with its components. It uses the predefined CSS, JQuery language to incorporate in different frameworks. In this article we will know how to use Radion Addons in ReactJS
3 min read
ReactJS Semantic UI Portal Addons
Semantic UI is a modern framework used in developing seamless designs for the website. It gives the user a lightweight experience with its components. It uses the predefined CSS and JQuery languages to incorporate them into different frameworks. In this article, we will find out how to use Portal Ad
2 min read