Action buttons in React Card component
1 Dec 202317 minutes to read
You can include Action buttons within the Card and customize them. Action button is a div
element with e-card-actions
class followed by button tag or anchor tag within the card root element.
- For adding action buttons you can create button or anchor tag with
e-card-btn
class within the card action element.
<div className = "e-card">
<div className="e-card-actions">
<button className="e-card-btn"></button>
<a href="#"></a>
</div>
</div>
Vertical
By default, action buttons positioned in horizontal alignment , and also it can be aligned to show in vertical alignment by adding e-card-vertical
class.
<div className = "e-card">
<div className="e-card-actions e-card-vertical">
<button className="e-card-btn">More</button>
<a href="#">Share</a>
</div>
</div>
[Class-component]
import * as React from "react";
import * as ReactDOM from "react-dom";
export default class ReactApp extends React.Component {
render() {
return (<div>
<div id="sample">
<div className="e-card">
<div className="e-card-header-title">Eiffel Tower</div>
<div className="e-card-content">
The Eiffel Tower is acknowledged as the universal symbol of Paris and France.
</div>
<div className="e-card-actions">
<button className="e-card-btn">
<img src='./fav.png' title="Bookmark"/>
</button>
<button className="e-card-btn">
<img src='./like.png' title="Like"/>
</button>
<button className="e-card-btn">
<img src='./share.png' title="Share"/>
</button>
</div>
</div>
</div>
<div id="sample">
<div className="e-card">
<div className="e-card-header-title">Eiffel Tower</div>
<div className="e-card-content">
The Eiffel Tower is acknowledged as the universal symbol of Paris and France.
</div>
<div className="e-card-actions e-card-vertical">
<button className="e-card-btn">More</button>
<a href="#">Share</a>
</div>
</div>
</div>
</div>);
}
}
ReactDOM.render(<ReactApp />, document.getElementById("element"));
import * as React from "react";
import * as ReactDOM from "react-dom";
export default class ReactApp extends React.Component<{}, {}> {
public render() {
return (
<div>
<div id="sample">
<div className="e-card">
<div className="e-card-header-title">Eiffel Tower</div>
<div className="e-card-content">
The Eiffel Tower is acknowledged as the universal symbol of Paris and France.
</div>
<div className="e-card-actions">
<button className="e-card-btn">
<img src='./fav.png' title="Bookmark" />
</button>
<button className="e-card-btn">
<img src='./like.png' title="Like" />
</button>
<button className="e-card-btn">
<img src='./share.png' title="Share" />
</button>
</div>
</div>
</div>
<div id="sample">
<div className="e-card">
<div className="e-card-header-title">Eiffel Tower</div>
<div className="e-card-content">
The Eiffel Tower is acknowledged as the universal symbol of Paris and France.
</div>
<div className="e-card-actions e-card-vertical">
<button className="e-card-btn">More</button>
<a href="#">Share</a>
</div>
</div>
</div>
</div>
);
}
}
ReactDOM.render(<ReactApp />, document.getElementById("element"));
<!DOCTYPE html>
<html lang="en">
<head>
<title>Syncfusion React Card Sample</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Essential JS 2 for React Components" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-layouts/styles/material.css" rel="stylesheet" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='element'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>
[Functional-component]
import * as React from "react";
import * as ReactDOM from "react-dom";
function ReactApp() {
return (<div>
<div id="sample">
<div className="e-card">
<div className="e-card-header-title">Eiffel Tower</div>
<div className="e-card-content">
The Eiffel Tower is acknowledged as the universal symbol of Paris and France.
</div>
<div className="e-card-actions">
<button className="e-card-btn">
<img src='./fav.png' title="Bookmark"/>
</button>
<button className="e-card-btn">
<img src='./like.png' title="Like"/>
</button>
<button className="e-card-btn">
<img src='./share.png' title="Share"/>
</button>
</div>
</div>
</div>
<div id="sample">
<div className="e-card">
<div className="e-card-header-title">Eiffel Tower</div>
<div className="e-card-content">
The Eiffel Tower is acknowledged as the universal symbol of Paris and France.
</div>
<div className="e-card-actions e-card-vertical">
<button className="e-card-btn">More</button>
<a href="#">Share</a>
</div>
</div>
</div>
</div>);
}
ReactDOM.render(<ReactApp />, document.getElementById("element"));
import * as React from "react";
import * as ReactDOM from "react-dom";
function ReactApp () {
return (
<div>
<div id="sample">
<div className="e-card">
<div className="e-card-header-title">Eiffel Tower</div>
<div className="e-card-content">
The Eiffel Tower is acknowledged as the universal symbol of Paris and France.
</div>
<div className="e-card-actions">
<button className="e-card-btn">
<img src='./fav.png' title="Bookmark" />
</button>
<button className="e-card-btn">
<img src='./like.png' title="Like" />
</button>
<button className="e-card-btn">
<img src='./share.png' title="Share" />
</button>
</div>
</div>
</div>
<div id="sample">
<div className="e-card">
<div className="e-card-header-title">Eiffel Tower</div>
<div className="e-card-content">
The Eiffel Tower is acknowledged as the universal symbol of Paris and France.
</div>
<div className="e-card-actions e-card-vertical">
<button className="e-card-btn">More</button>
<a href="#">Share</a>
</div>
</div>
</div>
</div>
);
}
ReactDOM.render(<ReactApp />, document.getElementById("element"));
<!DOCTYPE html>
<html lang="en">
<head>
<title>Syncfusion React Card Sample</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Essential JS 2 for React Components" />
<meta name="author" content="Syncfusion" />
<link href="https://cdn.syncfusion.com/ej2/27.2.2/ej2-layouts/styles/material.css" rel="stylesheet" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='element'>
<div id='loader'>Loading....</div>
</div>
</body>
</html>