Function ControlButtonsComponent

ControlButtonsComponent is a React functional component that renders a set of customizable control buttons.

This component organizes an array of buttons, each with options for icons, background color, and custom behavior. It supports horizontal or vertical layout and flexible alignment within the container.

import React from 'react';
import { ControlButtonsComponent } from 'mediasfu-reactjs';
import { faPlay, faPause, faStop } from '@fortawesome/free-solid-svg-icons';

function App() {
const buttons = [
{
name: 'Play',
icon: faPlay,
onPress: () => console.log('Play button pressed'),
backgroundColor: { default: 'green' },
active: true,
},
{
name: 'Pause',
icon: faPause,
onPress: () => console.log('Pause button pressed'),
backgroundColor: { default: 'red' },
},
{
name: 'Stop',
icon: faStop,
onPress: () => console.log('Stop button pressed'),
},
];

return (
<ControlButtonsComponent
buttons={buttons}
buttonBackgroundColor={{ default: 'transparent', pressed: 'gray' }}
alignment="flex-start"
vertical={false}
buttonsContainerStyle={{ padding: 10 }}
/>
);
}

export default App;

Properties

propTypes?: WeakValidationMap<ControlButtonsComponentOptions>

Used to declare the types of the props accepted by the component. These types will be checked during rendering and in development only.

We recommend using TypeScript instead of checking prop types at runtime.

contextTypes?: ValidationMap<any>

Lets you specify which legacy context is consumed by this component.

defaultProps?: Partial<ControlButtonsComponentOptions>

Used to define default values for the props accepted by the component.

type Props = { name?: string }

const MyComponent: FC<Props> = (props) => {
return <div>{props.name}</div>
}

MyComponent.defaultProps = {
name: 'John Doe'
}
displayName?: string

Used in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.


const MyComponent: FC = () => {
return <div>Hello!</div>
}

MyComponent.displayName = 'MyAwesomeComponent'