Skip to main content

SDK Props Reference

VoteNowButton Props

PropTypeRequiredDescription
URLstringRequiredThe voting URL obtained from the VOTR API.
labelstringOptionalButton text. Defaults to "Vote Now".
buttonStyleViewStyleOptionalCustom styling for the button container.
textStyleTextStyleOptionalCustom styling for the button label text.
isDisabledbooleanOptionalWhether the button is disabled.
onPress() => voidOptionalCalled when the button is pressed.
onSuccess() => voidOptionalCalled when voting completes successfully.
onError(error: string) => voidOptionalCalled when an error occurs during the voting flow.
onBack() => voidOptionalCalled when the user closes the voting modal.

Example with All Props

VoteButton.tsx — every prop wired up
<VoteNowButton
URL={votingUrl}
label="Submit Your Vote"
buttonStyle={{
backgroundColor: "#28a745",
borderRadius: 12,
paddingVertical: 16,
paddingHorizontal: 32,
elevation: 3,
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 3.84,
}}
textStyle={{
color: "#ffffff",
fontSize: 18,
fontWeight: "600",
textAlign: "center",
}}
isDisabled={!votingUrl}
onPress={() => console.log("Vote button pressed")}
onSuccess={() => {
Alert.alert("Success", "Vote submitted successfully!");
navigation.goBack();
}}
onError={(error) => {
console.error("Voting error:", error);
Alert.alert("Error", "Failed to submit vote. Please try again.");
}}
onBack={() => {
console.log("User cancelled voting");
}}
/>

Advanced Usage with Custom Styling

VoteButton.tsx — branded button with custom shadow
<VoteNowButton
URL={votingUrl}
label="Cast Your Vote"
buttonStyle={{
backgroundColor: "#007AFF",
borderRadius: 8,
paddingVertical: 12,
paddingHorizontal: 24,
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
}}
textStyle={{
color: "white",
fontSize: 16,
fontWeight: "bold",
}}
onSuccess={() => {
Alert.alert("Success", "Your vote has been recorded!");
}}
onError={(error) => {
Alert.alert("Error", `Voting failed: ${error}`);
}}
/>