Skip to content

Types Reference

The library exports a default component and several TypeScript types:

// Default component
import SoccerLineUp from 'react-soccer-lineup';
// Type imports
import SoccerLineUp, {
type Team,
type TeamStyle,
type Squad,
type Player,
type PlayerStyle,
type PlayerPattern,
type PlayerOffset,
type PitchSize,
type PitchPattern,
type PitchOrientation,
type PitchViewProps
} from 'react-soccer-lineup';

Main component props interface.

interface PitchViewProps {
color?: string;
size?: PitchSize;
pattern?: PitchPattern;
orientation?: PitchOrientation;
homeTeam?: Team;
awayTeam?: Team;
}

Pitch dimension options.

type PitchSize = 'small' | 'normal' | 'big' | 'responsive' | 'fill';

Available grass patterns.

type PitchPattern = 'lines' | 'squares' | 'circles';

Pitch orientation options.

type PitchOrientation = 'horizontal' | 'vertical';

Team configuration object.

type Team = {
squad: Squad;
style?: TeamStyle;
};

Player positions within a team. All positions are optional.

type Squad = {
gk?: Player | null | undefined;
df?: (Player | null | undefined)[];
cdm?: (Player | null | undefined)[];
cm?: (Player | null | undefined)[];
cam?: (Player | null | undefined)[];
fw?: (Player | null | undefined)[];
};
KeyFull NameDescription
gkGoalkeeperSingle player in goal
dfDefendersBack line players
cdmCentral Defensive MidfieldersDefensive midfield line
cmCentral MidfieldersMain midfield line
camCentral Attacking MidfieldersAttacking midfield line
fwForwardsAttacking line

Styling options for teams.

type TeamStyle = {
color?: string;
borderColor?: string;
numberColor?: string;
numberBackgroundColor?: string;
nameColor?: string;
nameBackgroundColor?: string;
pattern?: PlayerPattern;
patternColor?: string;
};
export type PlayerPattern =
| 'lines'
| 'thin-lines'
| 'thick-lines'
| 'stripes'
| 'thin-stripes'
| 'thick-stripes'
| 'line'
| 'thin-line'
| 'thick-line'
| 'stripe'
| 'thin-stripe'
| 'thick-stripe'
| 'bar'
| 'thin-bar'
| 'thick-bar'
| 'bars'
| 'thin-bars'
| 'thick-bars'
| 'left-half'
| 'right-half'
| 'top-half'
| 'bottom-half'
| 'left-slash'
| 'left-thin-slash'
| 'left-thick-slash'
| 'right-slash'
| 'right-thin-slash'
| 'right-thick-slash'
| 'cross'
| 'x'
| 'squares'
| 'none';

Individual player configuration.

type Player = {
name?: string;
number?: number;
style?: PlayerStyle;
offset?: PlayerOffset;
onClick?(): void;
};
PropertyTypeDescription
namestringPlayer name displayed below the marker
numbernumberJersey number displayed on the marker
stylePlayerStyleIndividual player styling (overrides team style)
offsetPlayerOffsetPosition adjustment
onClick() => voidCallback when player marker is clicked

Styling options for individual players. The player’s style takes precedence over the team’s style.

type PlayerStyle = {
color?: string;
borderColor?: string;
numberColor?: string;
numberBackgroundColor?: string;
nameColor?: string;
nameBackgroundColor?: string;
pattern?: PlayerPattern;
patternColor?: string;
};
PropertyDescriptionHome DefaultAway Default
colorMarker fill color#ffffff#333333
borderColorMarker border color#ffffff#333333
numberColorPlayer number text color#333333#ffffff
nameColorPlayer name text color#333333#ffffff
nameBackgroundColorName label backgroundtransparenttransparent
patternPlayer patternnonenone
patternColorPlayer pattern colortransparenttransparent

Position adjustment for fine-tuning player placement.

type PlayerOffset = {
x?: number;
y?: number;
};
PropertyTypeDefaultDescription
xnumber0Horizontal offset (negative = left, positive = right)
ynumber0Vertical offset (negative = up, positive = down)
import SoccerLineUp, {
type Team,
type Squad,
type Player,
type TeamStyle
} from 'react-soccer-lineup';
function App() {
const playerStyle: TeamStyle = {
color: '#c8102e',
borderColor: '#ffffff',
numberColor: '#ffffff'
};
const captain: Player = {
name: 'Captain',
number: 10,
style: playerStyle,
offset: { x: 10, y: -5 },
onClick: () => console.log('Captain clicked!')
};
const squad: Squad = {
gk: { number: 1 },
df: [{ number: 2 }, { number: 4 }, { number: 5 }, { number: 3 }],
cm: [{ number: 6 }, { number: 8 }, captain, { number: 7 }],
fw: [{ number: 9 }, { number: 11 }]
};
const team: Team = {
squad,
style: { borderColor: '#c8102e' }
};
return (
<SoccerLineUp
color="#327d61"
pattern="lines"
size="responsive"
orientation="horizontal"
homeTeam={team}
/>
);
}